Laravel Notification Event Subscriber is a simple package that registers an event subscriber to make it easy to run code while sending notifications.
Specifically, this package allows you to run any action while a notification is being sent or after it has been sent:
3class UserRegisteredNotification extends Notification
5 /* ...Notification code... */
7 // Handlers for sending/sent events.
8 public function onSending(string $channel, $response = null): void
10 Log::info($this::class . ' is being sent via ' . $channel);
13 public function onSent(string $channel): void
15 Log::info($this::class . ' has been sent via ' . $channel);
It works by registering an event subscriber that listens to the
NotificationSent events, which checks to see if the notification class defines an
If you’d like to learn more about this package, check it out on GitHub at laravel-notification-event-subscriber.