From 234717b23c922ed8426bcc43df39aed87c95a95a Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Sun, 11 Jan 2026 12:09:58 +0100 Subject: [PATCH] multiplex user notifications over a single private channel --- app/Events/EventParticipationCancelled.php | 47 ++++++++++++++++++++ app/Events/TaskParticipationCancelled.php | 50 ++++++++++++++++++++++ app/Events/VolunteerAssignedToTask.php | 50 ++++++++++++++++++++++ app/Events/VolunteerUnassignedFromTask.php | 50 ++++++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 app/Events/EventParticipationCancelled.php create mode 100644 app/Events/TaskParticipationCancelled.php create mode 100644 app/Events/VolunteerAssignedToTask.php create mode 100644 app/Events/VolunteerUnassignedFromTask.php diff --git a/app/Events/EventParticipationCancelled.php b/app/Events/EventParticipationCancelled.php new file mode 100644 index 0000000..679fe7e --- /dev/null +++ b/app/Events/EventParticipationCancelled.php @@ -0,0 +1,47 @@ +userId = $userId; + $this->event = $event; + } + + /** + * Get the channels the event should broadcast on. + * + * @return array + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('user.' . $this->userId), + ]; + } + + public function broadcastAs() + { + return 'event.participation.cancelled'; + } +} diff --git a/app/Events/TaskParticipationCancelled.php b/app/Events/TaskParticipationCancelled.php new file mode 100644 index 0000000..2a45dd3 --- /dev/null +++ b/app/Events/TaskParticipationCancelled.php @@ -0,0 +1,50 @@ +userId = $userId; + $this->task = $task; + $this->event = $event; + } + + /** + * Get the channels the event should broadcast on. + * + * @return array + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('user.' . $this->userId), + ]; + } + + public function broadcastAs() + { + return 'task.participation.cancelled'; + } +} diff --git a/app/Events/VolunteerAssignedToTask.php b/app/Events/VolunteerAssignedToTask.php new file mode 100644 index 0000000..959dc0c --- /dev/null +++ b/app/Events/VolunteerAssignedToTask.php @@ -0,0 +1,50 @@ +userId = $userId; + $this->task = $task; + $this->event = $event; + } + + /** + * Get the channels the event should broadcast on. + * + * @return array + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('user.' . $this->userId), + ]; + } + + public function broadcastAs() + { + return 'volunteer.assigned.to.task'; + } +} diff --git a/app/Events/VolunteerUnassignedFromTask.php b/app/Events/VolunteerUnassignedFromTask.php new file mode 100644 index 0000000..5ff4e43 --- /dev/null +++ b/app/Events/VolunteerUnassignedFromTask.php @@ -0,0 +1,50 @@ +userId = $userId; + $this->task = $task; + $this->event = $event; + } + + /** + * Get the channels the event should broadcast on. + * + * @return array + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('user.' . $this->userId), + ]; + } + + public function broadcastAs() + { + return 'volunteer.unassigned.to.task'; + } +}