I understand that with Laravel notifications I can use
Notification::send(User::first(), new TodoCompleted($task));
But what if I want to send a notification, to Slack in my case, with some custom details stored in an array ( $task
in the example above) but without having to pass a entity/model ( User::first()
in the example above). Is that possible?
To send a notification without using model you will want to use on demand notifications :
Notification::route('slack', 'https://hooks.slack.com/services/...')
->notify(new TodoCompleted($task));
Just replace https://hooks.slack.com/services/...
with the url that you would usually return from the routNotificationForSlack
method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.