Laravel - create event and listener

https://medium.com/@InaniT0/laravels-events-and-listeners-are-just-kids-game-e0de15a19d9a

Laravel events has 3 parts to it: Event, Listener and the EventServiceProvider that defines them.

Create an event:

php artisan make:event ReceiptUploaded



Create a listener to this event

php artisan make:listener ContinueWithReceiptProcessing --event=ReceiptUploaded



Glue them together in App\Providers\EventServiceProvider

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        ReceiptUploaded::class => [
            ContinueWithReceiptProcessing::class,
        ],
    ];

    public function boot()
    {
        parent::boot();

        //
    }
}