Notifications, Events and Listeners

The Laravel framework provides many communication occurrences and observer implementation, allowing for simple notifiable events that occur in your application.

  1. Notifications
  2. Events and Listeners
  3. References


In addition to supporting sending emails, Laravel has support for notifications across mulitple channels, including SMS. Notifications can also be stored in a database so that they may be displayed on the application.

Creating Notifications

Notifications are stored within the directory app/Notifications. To create a new notification the make:notification Aristan command needs to be ran:

Simply add to the array 'database' to store the notification, see Database Notifications to create the table:

public function via($notifiable)
    return ['mail', 'database'];

Notifications usage example

Events and Listeners

Events are a great way to decouple various aspects of your application, events can have multiple listeners that do not depend on each other.

Creating Events and Listeners

Events are stored within the directory app/Events and Listeners within the directory app/Listeners. Events and Listeners are defined in the app/Providers/EventServiceProvider.php directory.

protected $listen = [
    'App\Events\EventName' => [

Then to create the new Events and Listeners run:

Events and Listeners usage example