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
How to create Controller Laravel - File Uploading ?
How do I set up the eloquent relationships between the aforementioned comments and authors, including creating the schema design?
What are bundles, reverse routing and the ioc container?
What do you mean by laravel dusk?
What is csrf protection?
Tell me is laravel an open source?
How to use aggregate functions in laravel query?
Define http middleware?
What are the requirements to install valet?
Explain request life cycle of laravel.
What is x-xsrf-token?
Explain collections in laravel.
Tell me when laravel was launched?
What are the three types of authentication?
How to install valet?