From 8c8fb946e18dd5522977189533cbcfab70462992 Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Sat, 28 Mar 2026 15:37:10 +0100 Subject: [PATCH] create TaskDeleted notification --- app/Notifications/TaskDeleted.php | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 app/Notifications/TaskDeleted.php diff --git a/app/Notifications/TaskDeleted.php b/app/Notifications/TaskDeleted.php new file mode 100644 index 0000000..401f2cf --- /dev/null +++ b/app/Notifications/TaskDeleted.php @@ -0,0 +1,64 @@ +web_notifications) { + $channels[] = 'database'; + $channels[] = 'broadcast'; + } + + if ($notifiable->email_notifications) { + $channels[] = 'mail'; + } + + return $channels; + } + + public function toDatabase($notifiable): array + { + return [ + 'message' => "La tâche {$this->task->name} pour l'événement {$this->event->name} a été supprimée. Vous n'y participez donc plus.", + 'task_id' => $this->task->id, + 'event_id' => $this->event->id, + ]; + } + + public function toBroadcast($notifiable): BroadcastMessage + { + return new BroadcastMessage($this->toDatabase($notifiable)); + } + + public function toMail($notifiable): void + { + Mail::to($notifiable->email)->send(new TaskParticipationCancelledMail([ + 'name' => $notifiable->name, + 'lastname' => $notifiable->lastname, + 'taskName' => $this->task->name, + 'start' => $this->event->start, + 'end' => $this->task->end, + 'eventName' => $this->event->name, + ])); + } +}