Files
SAE-BUT2-backend/app/Events/TaskParticipationCancelled.php
T
2026-03-18 11:07:58 +01:00

48 lines
1.1 KiB
PHP

<?php
namespace App\Events;
use App\Models\Events;
use App\Models\Task;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class TaskParticipationCancelled implements ShouldBroadcastNow
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $userId;
public $task;
public $event;
/**
* Create a new event instance.
*/
public function __construct($userId, Task $task, Events $event)
{
$this->userId = $userId;
$this->task = $task;
$this->event = $event;
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('user.' . $this->userId),
];
}
public function broadcastAs()
{
return 'task.participation.cancelled';
}
}