diff --git a/app/Notifications/VolunteerAssignedToTask.php b/app/Notifications/VolunteerAssignedToTask.php new file mode 100644 index 0000000..a64dd43 --- /dev/null +++ b/app/Notifications/VolunteerAssignedToTask.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' => "Vous avez été assigné à la tâche {$this->task->name} de l'événement {$this->event->name}.", + '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 VolunteerAssignToTaskMail([ + 'name' => $notifiable->name, + 'lastname' => $notifiable->lastname, + 'taskName' => $this->task->name, + 'start' => $this->task->start, + 'end' => $this->task->end, + 'eventName' => $this->event->name, + ])); + } +}