$data * @param array{name: string, mime: string, content: string}|null $attachment */ public function __construct( public readonly array $data, public readonly ?array $attachment = null, ) { } public function envelope(): Envelope { return new Envelope( subject: 'Nouveau message - Formulaire de contact', ); } public function content(): Content { return new Content( view: 'emails.contact', with: ['data' => $this->data], ); } /** * @return array */ public function attachments(): array { if ($this->attachment === null) { return []; } return [ Attachment::fromData( fn () => base64_decode($this->attachment['content']), $this->attachment['name'], )->withMime($this->attachment['mime']), ]; } }