build_email = $build_email; $this->user = $user; //this is inappropriate here, need to refactor 'user' in this context the 'user' could also be the 'system' $this->client = $client; } /** * Build the message. * * @return $this * @throws \Laracasts\Presenter\Exceptions\PresenterException */ public function build() { $template_name = 'email.template.'.$this->build_email->getTemplate(); $settings = $this->client->getMergedSettings(); $company = $this->client->company; $message = $this->from($this->user->email, $this->user->present()->name())//todo this needs to be fixed to handle the hosted version ->subject($this->build_email->getSubject()) ->text('email.template.plain', [ 'body' => $this->build_email->getBody(), 'footer' => $this->build_email->getFooter(), 'whitelabel' => $this->client->user->account->isPaid() ? true : false, 'settings' => $settings, ]) ->view($template_name, [ 'body' => $this->build_email->getBody(), 'footer' => $this->build_email->getFooter(), 'view_link' => $this->build_email->getViewLink(), 'view_text' => $this->build_email->getViewText(), 'title' => '', // 'title' => $this->build_email->getSubject(), 'signature' => $settings->email_signature, 'settings' => $settings, 'company' => $company, 'whitelabel' => $this->client->user->account->isPaid() ? true : false, ]); //conditionally attach files if ($settings->pdf_email_attachment !== false && ! empty($this->build_email->getAttachments())) { foreach ($this->build_email->getAttachments() as $file) { $message->attach($file); } } return $message; } }