Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 1.07 KB

basic-delayed-notification.md

File metadata and controls

23 lines (18 loc) · 1.07 KB

< Back to main README.md

Basic Delayed Notification Example (1 week)

  1. Add the SnoozeNotifiable trait to your notifiable model

  2. Create the basic notification: php artisan make:notification OneWeekAfterNotice

  3. Get the datetime for when we should send the notification

    • $sendAt = Carbon::now()->addDays(7) // 7 days from now
    • Here is a reference to Carbon if you need help creating future dates
    • Note: Make sure you have imported carbon with use Carbon\Carbon; at the top of your file
  4. Schedule the notification for a notifiable User

Auth::user()->notifyAt(new OneWeekAfterNotice(), $sentAt);
  1. Our notification will be saved in our scheduled_notifications table, and will be sent the first time our snooze:send command runs following the $send_at date.
Note: If you want to test, set the "sendAt" value to now (Carbon::now()) instead of 1 week. Then run `php artisan snooze:send` in your console.