From 9fbc09017b8f613552084d6df1acfcbe05c7cce3 Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Thu, 19 Mar 2026 18:09:11 +0100 Subject: [PATCH] add $notificationId to every broadcast notification --- app/Events/EventParticipationCancelled.php | 4 +++- app/Events/TaskDateUpdated.php | 4 +++- app/Events/TaskParticipationCancelled.php | 4 +++- app/Events/UserCreated.php | 4 +++- app/Events/VolunteerAssignedToTask.php | 4 +++- app/Events/VolunteerRoleUpdated.php | 4 +++- app/Events/VolunteerUnassignedFromTask.php | 4 +++- app/Http/Controllers/EventsController.php | 3 ++- app/Http/Controllers/TasksController.php | 4 ++++ app/Http/Controllers/UserController.php | 8 ++++++-- 10 files changed, 33 insertions(+), 10 deletions(-) diff --git a/app/Events/EventParticipationCancelled.php b/app/Events/EventParticipationCancelled.php index 23f04f0..015ba90 100644 --- a/app/Events/EventParticipationCancelled.php +++ b/app/Events/EventParticipationCancelled.php @@ -16,14 +16,16 @@ class EventParticipationCancelled implements ShouldBroadcastNow public $userId; public $event; + public $notificationId; /** * Create a new event instance. */ - public function __construct($userId, Event $event) + public function __construct($userId, Event $event, $notificationId) { $this->userId = $userId; $this->event = $event; + $this->notificationId = $notificationId; } /** diff --git a/app/Events/TaskDateUpdated.php b/app/Events/TaskDateUpdated.php index 9526a5b..dcf7fa1 100644 --- a/app/Events/TaskDateUpdated.php +++ b/app/Events/TaskDateUpdated.php @@ -18,18 +18,20 @@ class TaskDateUpdated implements ShouldBroadcastNow public $event; public $start; public $end; + public $notificationId; protected $userId; /** * Create a new event instance. */ - public function __construct($userId, Task $task, Event $event, $start, $end) + public function __construct($userId, Task $task, Event $event, $start, $end, $notificationId) { $this->userId = $userId; $this->task = $task; $this->event = $event; $this->start = $start; $this->end = $end; + $this->notificationId = $notificationId; } /** diff --git a/app/Events/TaskParticipationCancelled.php b/app/Events/TaskParticipationCancelled.php index df6ee78..698a10e 100644 --- a/app/Events/TaskParticipationCancelled.php +++ b/app/Events/TaskParticipationCancelled.php @@ -17,15 +17,17 @@ class TaskParticipationCancelled implements ShouldBroadcastNow public $userId; public $task; public $event; + public $notificationId; /** * Create a new event instance. */ - public function __construct($userId, Task $task, Event $event) + public function __construct($userId, Task $task, Event $event, $notificationId) { $this->userId = $userId; $this->task = $task; $this->event = $event; + $this->notificationId = $notificationId; } /** diff --git a/app/Events/UserCreated.php b/app/Events/UserCreated.php index ead5cf3..a27ee47 100644 --- a/app/Events/UserCreated.php +++ b/app/Events/UserCreated.php @@ -15,13 +15,15 @@ class UserCreated implements ShouldBroadcastNow public $user; + public $notificationId; /** * Create a new event instance. */ - public function __construct(User $user) + public function __construct(User $user, $notificationId) { $this->user = $user; + $this->notificationId = $notificationId; } /** diff --git a/app/Events/VolunteerAssignedToTask.php b/app/Events/VolunteerAssignedToTask.php index 120f17c..0b96aaf 100644 --- a/app/Events/VolunteerAssignedToTask.php +++ b/app/Events/VolunteerAssignedToTask.php @@ -16,16 +16,18 @@ class VolunteerAssignedToTask implements ShouldBroadcastNow public $task; public $event; + public $notificationId; protected $userId; /** * Create a new event instance. */ - public function __construct($userId, Task $task, Event $event) + public function __construct($userId, Task $task, Event $event, $notificationId) { $this->userId = $userId; $this->task = $task; $this->event = $event; + $this->notificationId = $notificationId; } /** diff --git a/app/Events/VolunteerRoleUpdated.php b/app/Events/VolunteerRoleUpdated.php index e73bd47..690d114 100644 --- a/app/Events/VolunteerRoleUpdated.php +++ b/app/Events/VolunteerRoleUpdated.php @@ -15,15 +15,17 @@ class VolunteerRoleUpdated implements ShouldBroadcastNow use Dispatchable, InteractsWithSockets, SerializesModels; public $role; + public $notificationId; protected $userId; /** * Create a new event instance. */ - public function __construct($userId, $role) + public function __construct($userId, $role, $notificationId) { $this->userId = $userId; $this->role = $role; + $this->notificationId = $notificationId; } /** diff --git a/app/Events/VolunteerUnassignedFromTask.php b/app/Events/VolunteerUnassignedFromTask.php index 70c1207..14f370b 100644 --- a/app/Events/VolunteerUnassignedFromTask.php +++ b/app/Events/VolunteerUnassignedFromTask.php @@ -17,15 +17,17 @@ class VolunteerUnassignedFromTask implements ShouldBroadcastNow public $userId; public $task; public $event; + public $notificationId; /** * Create a new event instance. */ - public function __construct($userId, Task $task, Event $event) + public function __construct($userId, Task $task, Event $event, $notificationId) { $this->userId = $userId; $this->task = $task; $this->event = $event; + $this->notificationId = $notificationId; } /** diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php index 117398e..080851e 100644 --- a/app/Http/Controllers/EventsController.php +++ b/app/Http/Controllers/EventsController.php @@ -107,7 +107,8 @@ class EventsController extends Controller foreach ($participants as $user) { broadcast(new EventParticipationCancelled( $user->id, - $event + $event, + $notification->id, )); $data = [ diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php index e08bd52..412ef0d 100644 --- a/app/Http/Controllers/TasksController.php +++ b/app/Http/Controllers/TasksController.php @@ -107,6 +107,7 @@ class TasksController extends Controller $user->id, $task, $event, + $notification->id, )); $data = [ @@ -171,6 +172,7 @@ class TasksController extends Controller $user->id, $task, $event, + $notification->id, )); $data = [ @@ -224,6 +226,7 @@ class TasksController extends Controller $event, FormatDate::formatDate($request["start"]), FormatDate::formatDate($request["end"]), + $notification->id, )); $data = [ @@ -306,6 +309,7 @@ class TasksController extends Controller $user->id, $task, $event, + $notification->id, )); $data = [ diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 58e6772..2622071 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -61,7 +61,10 @@ class UserController extends Controller $notification->users()->attach( $admins->pluck('id')->toArray() ); - broadcast(new UserCreated($user)); + broadcast(new UserCreated( + $user, + $notification->id, + )); foreach ($admins as $admin) { $data = [ @@ -263,7 +266,8 @@ class UserController extends Controller broadcast(new VolunteerRoleUpdated( $user->id, - $role + $role, + $notification->id, )); $data = [