You can install the package via composer:
composer require spatie/laravel-notification-log
You can publish and run the migrations with:
php artisan vendor:publish --tag="notification-log-migrations"
php artisan migrate
##Publishing the config file
Optionally, you can publish the config file with:
php artisan vendor:publish --tag="notification-log-config"
This is the contents of the published config file:
return [
'model' => Spatie\NotificationLog\Models\NotificationLogItem::class,
'prune_after_days' => 30,
'log_all_by_default' => config('notification-log.log_all_by_default'),
'actions' => [
'convertEventToModel' => Spatie\NotificationLog\Actions\ConvertNotificationSendingEventToLogItemAction::class
],
'event_subscriber' => Spatie\NotificationLog\NotificationEventSubscriber::class,
];
##Pruning results
This package will store all sent notifications in the notification_log_items
table. The related NotificationLogItems
models uses the Laravel's MassPrunable
trait. In the notification-log
config file, you can specify the maximum age of a model in the prune_after_days
key. Don't forget to schedule the model:prune
command, as instructed in Laravel's docs. You'll have to explicitly add the model class:
class Kernel extends ConsoleKernel
{
protected function schedule(Schedule $schedule)
{
$schedule->command('model:prune', [
'--model' => [
\Spatie\NotificationLog\Models\NotificationLogItem::class,
],
])->daily();
}
}