invoice->status === 'paid' ? "Your Host UK Invoice #{$this->invoice->invoice_number}" : "Invoice #{$this->invoice->invoice_number} - Payment Required"; return new Envelope( subject: $subject, ); } /** * Get the message content definition. */ public function content(): Content { $this->invoice->load(['workspace', 'items']); return new Content( markdown: 'commerce::emails.invoice-generated', with: [ 'invoice' => $this->invoice, 'workspace' => $this->invoice->workspace, 'items' => $this->invoice->items, 'isPaid' => $this->invoice->status === 'paid', 'viewUrl' => route('hub.billing.invoices.view', $this->invoice), 'downloadUrl' => route('hub.billing.invoices.pdf', $this->invoice), ], ); } /** * Get the attachments for the message. * * @return array */ public function attachments(): array { // Only attach PDF if it exists if (! $this->invoice->pdf_path) { return []; } $disk = config('commerce.pdf.storage_disk', 'local'); if (! Storage::disk($disk)->exists($this->invoice->pdf_path)) { return []; } return [ Attachment::fromStorageDisk($disk, $this->invoice->pdf_path) ->as("invoice-{$this->invoice->invoice_number}.pdf") ->withMime('application/pdf'), ]; } }