In my project after someone fill a pricequote I want to send an email for him/her. In the controller I made an array what I want to pass to the mailable, to show on the email.
Where I'm now:
$params = array(
'name' => $name, //user's data
'email' => $email,
'phone' => $phone,
'data' => $data, //other stuffs in the form
);
Mail::to($email)
->send(new pricequote($params));
And after that how to pass from the mailable class to the template?
You can use;
namespace App\Mail;
public function __construct($data)
{
$this->data = $data;
}
public function build()
{
return $this->view('emails.contacts')
->with(['data' => $this->data]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With