diff --git a/app/Notifications/EventDeleted.php b/app/Notifications/EventDeleted.php new file mode 100644 index 0000000..587ae28 --- /dev/null +++ b/app/Notifications/EventDeleted.php @@ -0,0 +1,58 @@ +web_notifications) { + $channels[] = 'database'; + $channels[] = 'broadcast'; + } + + if ($notifiable->email_notifications) { + $channels[] = 'mail'; + } + + return $channels; + } + + public function toDatabase($notifiable): array + { + return [ + 'message' => "L'événement {$this->event->name} a été supprimé. Vous n'y participez donc plus.", + '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 EventParticipationCancelledMail([ + 'name' => $notifiable->name, + 'lastname' => $notifiable->lastname, + 'eventName' => $this->event->name, + 'start' => $this->event->start, + 'end' => $this->event->end, + ])); + } +}