How do I add a custom event to a Service Provider?
Laravel events provide an observer implementation, allowing you to listen and observe for specific tasks happening in your application. Adding a custom event to a ServiceProvider means that the application will listen to it as soon as it occurs. In terms of choosing the right ServiceProvider for the job, it breaks down into two options: a Module ServiceProvider, or any of the Providers listed under app/Providers of our shop’s root directory.
The ServiceProvider class has a $listen property, to which we simply add on the Event that we wish to add, alongside its listener.
Still have questions? If you didn't find what you need, you can ask us questions and generally stay up-to-date with all things Aero by joining our Slack community. Alternatively you can reach out to use via our website.