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, + ])); + } +}