contact = $contact; } /** * Build the message. * * @return $this */ public function build() { $data = $this->contact; $this->joinFileIfProvided(); return $this->subject('Contact - ' . config('theme.site_name', 'Boutique') . " - " . $data->subject) ->from($data->email) ->markdown('back::emails.send-contact', compact('data')); } /** * Attach a joined file if given in data * * @return void * @throws \RuntimeException If the mimetype cannot be guessed. */ protected function joinFileIfProvided(): void { if ($this->contact->file and File::exists($this->contact->file)) { $extension = File::guessExtension($this->contact->file) ?? File::extension($this->contact->file); $mimeType = File::mimeType($this->contact->file); if (!$mimeType) { throw new \RuntimeException('Could not guess joined file mimetype'); } $this->joinedFileName = sprintf( 'BOUTIQUE_MESSAGE-PJ-%s.%s', date("YmdHis"), $extension ); $this->attach($this->contact->file, [ 'as' => $this->joinedFileName, 'mime' => $mimeType ]); } } }