I would like to pass in a custom email template from database and I have seen where you can use setBody() however when I try to do that I get the following alarm
Call to undefined method App\Mail\StatusUpdate::setBody()
So to send an email I do the following. In my controller
try {
Mail::to($client->email)->send(new StatusUpdate(['engagement' => $engagement, 'client' => $client]));
return response()->json(['message' => 'The Contact Has Been Notified']);
} catch(\Exception $e) {
$e->getMessage();
}
And then in my StatusUpdate mailable class
public function build()
{
$template = EmailTemplate::where('title', 'Status Update')->first();
if($sender->has_spouse == true) {
$spouse_email = $sender->spouse_email;
return $this->replyTo($email, $name)
->cc($spouse_email)
->bcc($email, $name)
->subject($template->subject . $account->business_name)
->setBody($template->html_template, 'text/html')
};
}
Should I instead pass another parameter in on my controller method Mail::to?