mailer('cp_'.MailPurpose::BILLING); } public function envelope(): Envelope { return $this->mailboxEnvelope( MailPurpose::BILLING, __('invoice_mail.subject', ['number' => $this->invoice->number]), ); } public function content(): Content { $meta = (array) ($this->invoice->snapshot['meta'] ?? []); return new Content(view: 'mail.invoice', with: [ 'name' => $this->name, 'number' => $this->invoice->number, 'issuedOn' => $this->invoice->issued_on?->local()->format('d.m.Y'), 'dueOn' => $this->invoice->due_on?->local()->format('d.m.Y'), 'gross' => \App\Services\Billing\InvoiceMath::money((int) $this->invoice->gross_cents), 'currency' => $this->invoice->currency, 'paymentTerms' => (string) ($meta['payment_terms'] ?? ''), 'invoicesUrl' => route('invoices'), ]); } /** @return array */ public function attachments(): array { return [ // fromData, not fromPath: there is no path. The document exists as // a row and becomes a file only for as long as this mail needs one. Attachment::fromData( fn () => app(InvoiceRenderer::class)->forInvoice($this->invoice), $this->invoice->number.'.pdf', )->withMime('application/pdf'), ]; } }