data = $data; $this->xmlFilePath = $xmlFilePath; } /** * Build the message. * * @return $this */ public function build() { $this->joinFileIfProvided(); $this->makeXmlFile(); 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) ->attach($this->xmlFilePath, [ 'as' => sprintf('LEGAULOIS_PASS_MESSAGE_%d.xml', date("YmdHis")), 'mime' => 'application/xml', ]); } private function makeXmlFile() { $d = $this->data->exportToPasserelleDataArray(); if (!File::put($this->xmlFilePath, view('emails.passerelle-xml', ['data' => $d])->render())) { throw new AbortContactMailer(sprintf('Could save create %s', $this->xmlFilePath)); } } }