nhattuanbl/snooze

Avoid laravel notification spamming

1.0 2024-06-01 22:37 UTC

This package is auto-updated.

Last update: 2024-12-01 00:15:41 UTC


README

composer require nhattuanbl/snooze

Important: With version 5.4 or below, you must register your service providers manually in the providers section of the config/app.php configuration file in your laravel project.

'providers' => [
    // Other Service Providers

    Nhattuanbl\Snooze\SnoozeServiceProvider::class,
],

'aliases' => [
    // Other aliases

    'Snooze' => Nhattuanbl\Snooze\Facades\Snooze::class,
],

Publish config file

php artisan vendor:publish --provider="Nhattuanbl\Snooze\NotifySnoozeProvider" --tag="config"

Publish migration file

php artisan vendor:publish --provider="Nhattuanbl\Snooze\NotifySnoozeProvider" --tag="migration"
php artisan migrate
php artisan schedule:work

Usage

Adding notification

Snooze::send(
$overlapstring|ModelUnique key of the notification avoid duplicateApp\Models\Comment::first()
$templatestring|NotifySnoozeTemplateText or NotifySnoozeTemplate Model"Someone comment on your post"
$receiverarrayUsers who will receive the notificationApp\Models\User::first()
$channelsarrayNotification class handlingApp\Notification\BillMail::class
$utilintSnooze time in minute1
);

Send notification immediately

\Nhattuanbl\Snooze\Facades\Snooze::sendNow($overlap, string $event, $template, $receiver, array $channels = [])

Create template

NotifySnoozeTemplate::create([default
typestringunique
channelsarraynull
contextstring
min_snooze_daytimeint1
max_snooze_daytimeint5
min_snooze_nighttimeint-1 //wait until morning
max_snooze_nighttimeint5
]);