diff --git a/app/Notifications/UserRegistered.php b/app/Notifications/UserRegistered.php new file mode 100644 index 0000000..8188d0e --- /dev/null +++ b/app/Notifications/UserRegistered.php @@ -0,0 +1,61 @@ +web_notifications) { + $channels[] = 'database'; + $channels[] = 'broadcast'; + } + + if ($notifiable->email_notifications) { + $channels[] = 'mail'; + } + + return $channels; + } + + public function toDatabase($notifiable): array + { + return [ + 'message' => "Nouvelle demande d'inscription : {$this->user->name} {$this->user->lastname}", + 'user_id' => $this->user->id, + ]; + } + + public function toBroadcast($notifiable): BroadcastMessage + { + return new BroadcastMessage($this->toDatabase($notifiable)); + } + + public function toMail($notifiable): MailMessage + { + Mail::to($notifiable->email)->send(new RegisterMail([ + 'adminName' => $notifiable->name, + 'adminLastname'=> $notifiable->lastname, + 'userName' => $this->user->name, + 'userLastname' => $this->user->lastname, + ])); + + return (new MailMessage); + } +}