create broadcast notification when the user role is updated

This commit is contained in:
2026-03-19 17:11:34 +01:00
parent bda5aa4d50
commit 16ae03e6e6
2 changed files with 52 additions and 1 deletions
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace App\Events;
use App\Models\Event;
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 VolunteerRoleUpdated implements ShouldBroadcastNow
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $role;
protected $userId;
/**
* Create a new event instance.
*/
public function __construct($userId, $role)
{
$this->userId = $userId;
$this->role = $role;
}
/**
* 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 'volunteer.role.updated';
}
}