Laravel - Notifications - On Demand Notifications
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:
Notification::route('mail', '[email protected]')
->route('nexmo', '5555555555')
->route('slack', 'https://hooks.slack.com/services/...')
->notify(new InvoicePaid($invoice));
If you would like to provide the recipient's name when sending an on-demand notification to the mail
route, you may provide an array that contains the email address as the key and the name as the value of the first element in the array:
Notification::route('mail', [
'[email protected]' => 'Barrett Blair',
])->notify(new InvoicePaid($invoice));