Laravel 5: Events – Event

Scheduler: Events – Event

Event – Usage.

When you register event using Artisan command, e.g.:

… you get this template:

 But even something like this would work:

Since almost all work happens in Listeners, Event file can be really quite barren.

We need it to fire events.

We need it to associate events to Listeners, which BTW will do some real heavy lifting, responding to Event.

But that is about it.

Of course, I am not saying to get rid of all that stuff from auto-generated template.
Keep it.

Sometimes, you can pass some specific data via Event class.
e.g., take a look at this code:

We are assigning particular Order object, which triggered event and we are passing it to Listeners via __construct().

But, this is pretty much, what Event is going (in general) sweat for you.