29.07.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Events 246<br />

Generating Event / Listener Classes<br />

Of course, manually creating the files for each event and listener is cumbersome. Instead, simply<br />

add listeners and events to your EventServiceProvider and use the event:generate command.<br />

This command will generate any events or listeners that are listed in your EventServiceProvider.<br />

Of course, events and listeners that already exist will be left untouched:<br />

.<br />

1 php artisan event:generate<br />

Defining Events<br />

An event class is simply a data container which holds the information related to the event. For<br />

example, let’s assume our generated PodcastWasPurchased event receives an Eloquent ORM object:<br />

.<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!