be-park/eventer

Improve laravel listener and register event in database making them restorable

v4.1 2020-10-01 13:17 UTC

This package is auto-updated.

Last update: 2024-10-29 05:46:55 UTC


README

  • This package improve the way laravel manage his listener to be able to listen on parent class of the event
  • This package allow storing the event in the database in order to make them restorable

Installation

Add an Extends from Bepark\Eventer\EventServiceProvider to the event provider class App\Provider\EventServiceProvider

With just this installation the event will be saved in your database.

You can also publish the config file php artisan vendor:publish --provider="Bepark\Eventer\AppServiceProvider". You'll be able to set listen_on_eloquent to also store all eloquent event generated by Laravel

Listen on parent class

You can listen on the parent class of the triggered event by using the EventHelper. Check the StorableEventListener to see how it works.

listenWithChildren() will start listening on all event and will call the listener when it match.

Call it in the subscribe() method of your listener

EventHelper::listenWithChildren(Dispatcher $event, <ParentClass>, 'ListenerClass@method');