Get "PHP 8 in a Nuthshell" (Now comes with PHP 8.3)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

Delaying notifications channel-wise in Laravel 8.x

Up until now, if you would need to delay notifications, you could do it by chaining the delay method onto your notification instantiation like so.

$delay = now()->addMinutes(10);

$user->notify((new InvoicePaid($invoice))->delay($delay));

The problem with this is it will delay all the notification channels which has been associated with the notifications.

But thanks to a recent PR in Laravel 8.x which bring in the support for specifying delay per channel.

For instance, you can specify delay per channel by passing an array to the delay method to specify the delay amount for specific channels like so.

$user->notify((new InvoicePaid($invoice))->delay([
    'mail' => now()->addMinutes(5),
    'sms' => now()->addMinutes(10),

Interesting thing here to note is when using array, only channels specified in the array will get delayed. If a channel is not present in the array, it won’t be delayed.

Learn the fundamentals of PHP 8 (including 8.1, 8.2, and 8.3), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

Like this article? Consider leaving a


👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.