order = $order; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ public function via($notifiable) { // phpcs:enable return ['mail']; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage * @throws \RuntimeException If delivery status is unhandled. * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ public function toMail($notifiable) { // phpcs:enable if (!$this->order->delivery_status->equals(DeliveryStatus::ready())) { throw new \RuntimeException( "Unhandled notification for delivery status {$this->order->delivery_status->label}" ); } /** @var \App\Models\Shop\Timeslot */ $timeslot = $this->order->timeslot; /** @var \App\Models\Shop\Shop */ $shop = $timeslot->shop; /** @var \Illuminate\Support\Carbon */ $slot = $timeslot->slot; $mailMessage = (new MailMessage()) ->subject(\trans('Votre commande est prête - :appname', ['appname' => \config('app.name')])) ->greeting(trans('Votre commande avec pour référence :ref est désormais prête', [ 'ref' => $this->order->reference ])) ->line(\trans('Vous pouvez retrouver les informations la concernant, ainsi que le créneau de collecte qui vous est réservé, depuis votre espace personel.')) ->line(\trans('Voici un récap, au cas où :')) ->lines(\collect([ trans('boutique') => $shop->name, trans('téléphone') => $shop->phone, trans('adresse') => $shop->address, trans('ville') => "{$shop->postal_code} {$shop->city}" ])); if ($shop->gmaps_link_href) { $mailMessage->action(\trans('Voir sur la carte'), $shop->gmaps_link_href); } return $mailMessage ->line(\trans('Vous pourrez récupérer votre commande à la date suivante :')) ->line($slot->isoFormat('LLLL')) ->line('Merci d\'avoir utilisé notre application.'); } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ public function toArray($notifiable) { // phpcs:enable return [ 'order_id' => $this->order->id ]; } }