appUrl = $appUrl; $this->appHost = $appHost; $this->appName = Config::string('app.name', 'La Boutique de Cocotte'); } /** * Determine if the notification should be sent. */ public function shouldSend(Employee $notifiable, string $channel): bool { return ! Order::query() ->where('employee_matricule', $notifiable->matricule->value) ->whereDate('pickup_day', $this->pickupDay->format('Y-m-d')) ->where('status', OrderStatus::VALIDATED) ->exists(); } /** * @return array */ public function via(mixed $notifiable): array { return ['mail']; } public function toMail(mixed $notifiable): MailMessage { /** @var Employee $notifiable */ $cutoffDate = CarbonImmutable::instance($this->cutoffDate)->setTimezone('Europe/Paris'); $closureTime = $cutoffDate->format('G') . 'h'; $reminderDay = $cutoffDate->translatedFormat('l'); $reminderTime = $cutoffDate->subHours(2)->format('G') . 'h'; return (new MailMessage()) ->subject(trans(':time before order taking closes - :appname', [ 'time' => SendMissingOrderReminderJob::HOURS_BEFORE_CUTOFF . 'h', 'appname' => $this->appName, ])) ->markdown('emails.missing-order-reminder', [ 'employee' => $notifiable, 'deliveryDate' => $this->pickupDay->translatedFormat('d/m/Y'), 'closureTime' => $closureTime, 'reminderDay' => $reminderDay, 'reminderTime' => $reminderTime, 'appHost' => $this->appHost, 'appUrl' => $this->appUrl, ]) ->attachData($this->icsContent->value, 'rappel-commande.ics', [ 'mime' => 'text/calendar', ]); } }