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 |
How to register a middlewares in laravel controller?
What do you understand by database migrations in laravel? How can we use it?
Why do we use laravel?
What are the Features of Laravel ?
What is helper in laravel?
By default valet serve your app on which tld? How to configure it to use another domain?
What are route parameters?
How to generate pretty urls in laravel?
What is auth? How is it used?
What are the available router methods?
Do you know what is laravel elixir?
How to write html code in laravel controller?