44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class AdminNotificationCreated implements ShouldBroadcastNow
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public function __construct(
|
|
public readonly string $type,
|
|
public readonly string $title,
|
|
public readonly ?string $body = null,
|
|
public readonly ?string $link = null,
|
|
) {}
|
|
|
|
public function broadcastOn(): array
|
|
{
|
|
return [new PrivateChannel('admin-notifications')];
|
|
}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'admin.notification.created';
|
|
}
|
|
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'type' => $this->type,
|
|
'title' => $this->title,
|
|
'body' => $this->body,
|
|
'link' => $this->link,
|
|
];
|
|
}
|
|
}
|