find((int) $this->argument('abo')); if (! $abo) { $this->error('UserAbo '.$this->argument('abo').' nicht gefunden.'); return self::FAILURE; } $locale = $this->recipientLocale($abo); $originalLocale = App::getLocale(); App::setLocale($locale); try { $html = (new MailAboExecutionReminder($abo))->render(); } finally { App::setLocale($originalLocale); } $path = 'preview/abo-reminder-'.$abo->id.'.html'; Storage::disk('public')->put($path, $html); $url = preg_replace('#(?url($path)); $this->info("Reminder-Vorschau für Abo {$abo->id} (Locale {$locale}, ".($abo->is_for === 'me' ? 'Berater → Sales Center' : 'Endkunde → Portal').'):'); $this->line(' HTML: '.$url); $this->line(' Datei: '.Storage::disk('public')->path($path)); if ($send = $this->option('send')) { Mail::to($send)->locale($locale)->send(new MailAboExecutionReminder($abo)); $this->info(" Mail an {$send} versendet (siehe Mailpit)."); } return self::SUCCESS; } private function recipientLocale(UserAbo $abo): string { $locale = $abo->is_for === 'me' ? $abo->user?->getLocale() : $abo->shopping_user?->getLocale(); return $locale ?: 'de'; } }