[英]Send Laravel notification without entity
I understand that with Laravel notifications I can use 我明白使用Laravel通知我可以使用
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). 但是,如果我想在我的情况下向Slack发送通知,并在数组中存储一些自定义详细信息(上例中
$task
),但无需传递实体/模型( User::first()
上面的例子)。 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. 只需将您通常从
routNotificationForSlack
方法返回的url替换为https://hooks.slack.com/services/...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.