data = $data; $this->file = $file; } /** * Build the message. * * @return $this */ public function build() { if ($this->file) { $this->joinedFileName = sprintf( 'LEGAULOIS_PASS_MESSAGE-PJ-%s.%s', date("YmdHis"), File::extension($this->file) ); } return $this->view('emails.contact') ->subject(sprintf('Nouveau message consommateur Le Gaulois (%s)', $this->data->type->label())) ->text('emails.contact-plain') ->with('data', $this->data) ->attachData( view('emails.passerelle-xml', ['data' => $this->data->exportToPasserelleDataArray()])->render(), sprintf('LEGAULOIS_PASS_MESSAGE_%d.xml', date("YmdHis")), ['mime' => 'application/xml'] ); } /** * Get the attachments for the message. * * @return array */ public function attachments(): array { if (!$this->file) { return []; } return [ Attachment::fromPath($this->file)->as(sprintf( 'LEGAULOIS_PASS_MESSAGE-PJ-%s.%s', date("YmdHis"), File::extension($this->file) )), ]; } }