44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class NotifikasiCreated implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public function __construct(
|
|
public int $idUser,
|
|
public string $judul,
|
|
public string $pesan,
|
|
public string $tipe,
|
|
public int $unreadCount = 0,
|
|
) {}
|
|
|
|
public function broadcastOn(): array
|
|
{
|
|
return [new PrivateChannel('user.' . $this->idUser)];
|
|
}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'NotifikasiCreated';
|
|
}
|
|
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'judul' => $this->judul,
|
|
'pesan' => $this->pesan,
|
|
'tipe' => $this->tipe,
|
|
'unread_count' => $this->unreadCount,
|
|
];
|
|
}
|
|
}
|