是否可以在单个用户中拥有多个通知?我正在研究这种方法。第一个通知适用于数据库和广播频道。但是在第二个通知课上。它不起作用。
我的第二个通知类:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use App\TideUpdates;
class NewTideUpdate extends Notification
{
use Queueable;
public $user;
public function __construct($user)
{
$this->user = $user;
}
public function via($notifiable)
{
return ['database'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
public function toArray($notifiable)
{
return [
//
];
}
public function toDatabase($notifiable)
{
return [
'tideUpdate' => TideUpdates::orderBy('created_at', 'desc')->first()
];
}
}