transfer->loadMissing(['files', 'qrCode']); return (new MailMessage()) ->subject($this->subjectLine()) ->view('mail.notifications.transfer-owner-grace', [ 'transfer' => $transfer, 'milestone' => $this->milestone, 'daysRemaining' => $this->daysRemaining(), 'walletUrl' => 'https://'.config('app.account_domain', 'account.ladill.com').'/wallet', 'transferUrl' => route('transfer.transfers.show', $transfer), ]); } public function toArray(mixed $notifiable): array { return [ 'title' => $this->headline(), 'message' => $this->inAppMessage(), 'icon' => 'transfer', 'url' => route('transfer.transfers.show', $this->transfer), ]; } private function subjectLine(): string { return match ($this->milestone) { 'grace_entered' => "Payment needed: {$this->transfer->title} entered grace period", '1' => "Last day to save {$this->transfer->title} from deletion", '3' => "3 days left to save {$this->transfer->title}", '7' => "Reminder: {$this->transfer->title} will be deleted soon", default => "Transfer payment reminder: {$this->transfer->title}", }; } private function headline(): string { return match ($this->milestone) { 'grace_entered' => 'Transfer entered grace period', '1' => 'Files deleted tomorrow', default => 'Transfer deletion reminder', }; } private function inAppMessage(): string { $title = $this->transfer->title; return match ($this->milestone) { 'grace_entered' => "{$title} could not be renewed. Top up your wallet within the grace period to keep the files.", '1' => "{$title} will be deleted tomorrow unless your wallet is topped up.", default => "{$title} will be deleted in {$this->daysRemaining()} days unless payment is received.", }; } private function daysRemaining(): ?int { if ($this->milestone === 'grace_entered') { return null; } return is_numeric($this->milestone) ? (int) $this->milestone : null; } }