Working with Laravel Event-Easy to Send Register Email using Laravel Events


Laravel’s events provides a simple observer implementation, allowing you to subscribe and listen for various events that occur in your application. Event classes are typically stored in the app/Events directory, while their listeners are stored in app/Listeners.

You will not see Event and Listener Files before Generate it. So don’t worry, I am trying to understand you very easily.

First Step :  Go to App/Providers/EventServiceProvider.php

Change it instance of Before Code.

Step 2: Use Command to Generate Event and Listener

Step 3: You will see Two Files Generate in Events Folder bellow –

=> root/app/Events/SendMailEvent.php
=> root/app/Events/SendMailEListener.php

Step 4:

And Listener File Modified

Step 5:

Now go to App\Http\Controllers\Auth\RegisterController.php

Replace Code with Bellow: