我正在尝试使用laravel 6使用此处的文档向各个用户发送通知:https://laravel.com/docs/6.x/notifications#slack-notifications
我的from和to函数似乎什么都没做。
// call notification
Notification::route('slack', $slackUrl)->notify(new notifyHours($event->user));
App \ Notifications \ notifyHours
// send DM
public function toSlack($notifiable)
{
return (new SlackMessage())
->from('Puffin', ':puffin:') // doesn't seem to do anything
->to('@U4KFXXXXX') // doesn't seem to do anything
->image('https://XXX.png')
->content("Hi! Make sure I am up to date!")
->attachment(function(SlackAttachment $attachment) use ($notifiable) {
$attachment->title('Your Hours', 'https://xxx/tasks')
->fields([
'Today' => $this->hours->today.' hours',
'This Week' => 'You worked '.$this->hours->week. ' hours.'
]);
});
}
通知如何发送到整个通道,而不是我在to()函数中定义的用户?
根据代码,to()
方法仅接受一个频道,而不是该团队的用户。
/**
* Set the Slack channel the message should be sent to.
*
* @param string $channel
* @return $this
*/
public function to($channel)
{
$this->channel = $channel;
return $this;
}