Explain Events and Listeners ?
Answer / 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 |
What are the Advantages of Laravel ?
What do you mean by bundles?
How to generate application key in laravel?
How to assign multiple middleware to laravel route ?
What is reverse path filtering?
Please write some additional where clauses in laravel?
How to get last inserted id using laravel query?
What is service container in laravel?
What is difference between implicit and explicit route binding in laravel?
What is factory in laravel?
What is isset function?
How to serve sites with tls on valet?