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 the concept of events in laravel.
How to enable or disable maintenance mode in laravel?
What is heredoc syntax?
What is fillable in laravel model?
List the requirements to install valet?
What is meant by check method ?
Tell me what is the purpose of using dd() function iin laravel?
What is meant by Controller Middleware ?
How to enable or disable maintaince mode in laravel.
How will you explain dd() function in laravel?
What are the difference between latest() and oldest() in laravel?
How to install valet?
What is an api route?
What are the three service provider types?
How to get Retrieving the Request URI ?