*/ public array $issuer; public function __construct( public readonly User $user, public readonly Invoice $invoice, public readonly bool $isReminder = false, public readonly bool $attachPdf = true, public readonly bool $forInvoiceRecipient = false, ) { $renderer = app(ManualInvoicePdfRenderer::class); $this->invoicesUrl = route('me.invoices.index'); $this->bookingUrl = route('me.bookings.index'); $this->serviceName = $renderer->serviceName($invoice); $this->servicePeriod = $renderer->servicePeriod($invoice); $this->issuer = array_map(fn (mixed $value): string => (string) $value, (array) config('billing.issuer', [])); } public function envelope(): Envelope { // Die Fassung an die Rechnungs-E-Mail ist ein Duplikat — ohne Blindkopie. $bcc = $this->forInvoiceRecipient ? '' : (string) config('legal.contact_email'); $subject = $this->isReminder ? 'Zahlungserinnerung — Rechnung '.$this->invoice->number : 'Ihre Rechnung '.$this->invoice->number.' — Bestandsschutz auf pressekonto'; return new Envelope( subject: $subject, bcc: $bcc !== '' ? [$bcc] : [], ); } public function content(): Content { return new Content(view: 'emails.billing.manual-invoice-issued'); } /** * @return array */ public function attachments(): array { if (! $this->attachPdf) { return []; } $renderer = app(ManualInvoicePdfRenderer::class); return [ Attachment::fromData(fn (): string => $renderer->render($this->invoice), $renderer->filename($this->invoice)) ->withMime('application/pdf'), ]; } }