Laravel Notification Log is a package by Spatie to log notifications your Laravel app sends. This will allow you to query notification logs in the database for your app users:
// returns a collection of `NotificationLogItem` models$sentNotifications = $user->loggedNotifications();
You can customize which notifications get logged, and by default, all notifications are logged. Each notification can have custom logic by defining a shouldLog
method to determine if the notification should get logged:
use Illuminate\Notifications\Events\NotificationSending; // in a notificationpublic function shouldLog(NotificationSending $event): bool{ // i.e., custom logic to decide if a notification // should get logged... return true;}
Using this package, you can also query all logged notifications using a provided Eloquent model. This package offers additional customization options such as logging extra notification data, defining a notification fingerprint signature, and more. You can learn about all the options in the official documentation.
If you'd like to learn more, check out the source code on GitHub at spatie/laravel-notification-log and read Log all notifications sent by your Laravel app by Freek Van der Herten.
0 comments:
Post a Comment
Thanks