This is my package laravel-notification-event-subscriber

1.3.0 2023-02-19 14:49 UTC

This package is auto-updated.

Last update: 2023-11-19 16:23:21 UTC



Laravel Notification Event Subscriber

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package allows you to run any kind of actions while a notification is being sent or after it has been sent using onSent() and onSending() methods.

It registers an event subscriber NotificationEventSubscriber and listens to the NotificationSent and NotificationSending events of Laravel. When one of them is fired, the event subscriber runs a defined method according to the event.


You can install the package via composer:

composer require tkaratug/laravel-notification-event-subscriber


namespace App\Notifications;

use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Log;

class UserRegisteredNotification extends Notification
    public function via($notifiable): array
        return ['mail'];
    public function toMail($notifiable): MailMessage
        return (new MailMessage)
    public function onSending($notifiable, $channel, $response = null): void
        Log::info($this::class . ' is being sent to  via ' . $channel);
    public function onSent($notifiable, $channel): void
        Log::info($this::class . ' has been sent to  via ' . $channel);


composer test


Please see CHANGELOG for more information on what has changed recently.


Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.



The MIT License (MIT). Please see License File for more information.