• May 5, 2024
  • Chiwetara Igwe
  • 0

You can send Laravel Notifications not only to a certain user with $user->notify(), but also to anyone you want, via Notification::route(), with so-called “on-demand”.

Sometimes you may need to send a notification to someone who is not stored as a “user” of your application. Using the Notification facade’s route method, you may specify ad-hoc notification routing information before sending the notification:

use Illuminate\Broadcasting\Channel;
use Illuminate\Support\Facades\Notification;
 
Notification::route('mail', 'taylor@example.com')
            ->route('vonage', '5555555555')
            ->route('slack', '#slack-channel')
            ->route('broadcast', [new Channel('channel-name')])
            ->notify(new InvoicePaid($invoice));
Tags:

Chiwetara Igwe

I'm a full-stack developer, entrepreneur and owner of techbly.ng. I live in Nigeria and I love to write tutorials and tips that can help to other web developers. I am experienced in PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap. I am passionate about learning new things and keeping up with the latest trends and technologies.

http://techbly.ng

Leave a Reply

Your email address will not be published. Required fields are marked *

× Have a question?