From 42879b9d76ed544bf908fa2e0bcd826e12229e3d Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Sat, 28 Mar 2026 15:31:34 +0100 Subject: [PATCH] create VolunteerRoleUpdated notification --- app/Notifications/VolunteerRoleUpdated.php | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 app/Notifications/VolunteerRoleUpdated.php diff --git a/app/Notifications/VolunteerRoleUpdated.php b/app/Notifications/VolunteerRoleUpdated.php new file mode 100644 index 0000000..60bb9f9 --- /dev/null +++ b/app/Notifications/VolunteerRoleUpdated.php @@ -0,0 +1,55 @@ +web_notifications) { + $channels[] = 'database'; + $channels[] = 'broadcast'; + } + + if ($notifiable->email_notifications) { + $channels[] = 'mail'; + } + + return $channels; + } + + public function toDatabase($notifiable): array + { + return [ + 'message' => "Votre rôle a changé pour : {$this->role}", + 'role' => $this->role, + ]; + } + + public function toBroadcast($notifiable): BroadcastMessage + { + return new BroadcastMessage($this->toDatabase($notifiable)); + } + + public function toMail($notifiable): void + { + Mail::to($notifiable->email)->send(new UpdateRoleMail([ + 'name' => $notifiable->name, + 'lastname' => $notifiable->lastname, + 'role' => $this->role, + ])); + } +}