Answer Posted / surbhi
Events and Listeners serve a great way to decouple a web application, since one event can have multiple listeners which are independent of each other.
The events folder created by the artisan command includes the following two files
1. : event.php
2. :SomeEvent.php.
Event.php
<?php
namespace AppEvents;
abstract class Event{
//
}
As mentioned above, event.php includes the basic definition of class Event and calls for namespace AppEvents. Please note that the user defined or custom events are created in this file.
SomeEvent.php
For example, if we need to initialize order variable in the constructor for registering an event, we can do it in the following way -
public function __construct(Order $order)
{
$this->order = $order;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain how to upgrade valet to valet 2.0?
How to localize resource uris in laravel?
How do I log an error?
What is namespace in php laravel?
How to enable maintenance mode in laravel 5?
What is view laravel?
Which is better django or laravel?
What is helper in laravel?
What is the role of service provider?
Name aggregates methods of query builder.
What is blade template?
What is http / console kernels in laravel?
How to get Retrieving a Cookie in Laravel ?
What is eager loading in laravel?
Explain web.php route.