File size: 997 Bytes
5f32fbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | <?php
declare(strict_types=1);
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
class LiveNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
private $message,
private $link = '#',
private $title = null)
{
$this->message = $message;
$this->link = $link ?? '#';
$this->title = $title ?? __('New Notification');
}
public function via(object $notifiable): array
{
return ['broadcast', 'database'];
}
public function toArray(object $notifiable): array
{
return [
'user_id' => $notifiable->id,
'user_name' => $notifiable->name,
'data' => [
'message' => $this->message,
'link' => $this->link,
'title' => $this->title,
],
];
}
}
|