Php 在laravel中使用一个通知类发送多个通知
嗨,我有一个laravel通知类,我使用电报通道向电报发送通知。现在我想用一个类发送3个通知,下面是我的代码:Php 在laravel中使用一个通知类发送多个通知,php,laravel,Php,Laravel,嗨,我有一个laravel通知类,我使用电报通道向电报发送通知。现在我想用一个类发送3个通知,下面是我的代码: $task = Task::with('users')->findorfail($request->get('task_id')); foreach ($task->users as $item) { $task->notify(new TaskAssign($item,$task));
$task = Task::with('users')->findorfail($request->get('task_id'));
foreach ($task->users as $item) {
$task->notify(new TaskAssign($item,$task));
}
return 'done';
在我的任务分配中,我想使用以下方法:
public function via($notifiable)
{
return [TelegramChannel::class];
}
public function toTelegram($notifiable)
{
return TelegramLocation::create()
->to('108070198')
->latitude('40.6892494')
->longitude('-74.0466891');
// return
// TelegramMessage::create()
// // Optional recipient user id.
// ->to('')
// // Markdown supported.
// ->document('https://file-examples.com/wp-content/uploads/2017/10/file-sample_150kB.pdf', 'sample.pdf')
//
// // (Optional) Blade template for the content.
// // ->view('notification', ['url' => $url])
//
// // (Optional) Inline Buttons
//
}
现在我知道可以为每个类创建不同的类,但我希望在一个通知类中一起发送消息文件和位置。怎么能做到呢。谢谢