I am using laravel 5.4 scheduler to send an email by embedding(not attaching) images to the view. In the documentation, it has been mentioned that we can pass a $message variable into the view and use
{{ $message->embed('path/to/the/file') }}
in the view file.
My code is
//SendUserReport.php ~ (It is a Command class) public function handle(){ \Mail::to($mailList)->send(new GreetReport($data,$subscriber->id)); }
//UserReport.php ~ (It is a Mailable class) public function build(){ $data = $this->mailData; $id = $this->id; return $this->view('mails.reports.user-report', compact('data',)); }
How should I pass the $message variable using the above logic?
For the time being, I am able to pass the message variable using the code below without passing the control to the Mailable class (UserReport.php)
//SendUserReport.php ~ (It is a Command class) \Mail::send('mails.reports.user-report',compact('data'), function($message) use ($mailList){ $message->to($mailList)->subject('User Report for '.date('d-m-Y')); })
This code works fine and does well for my need, but I want to implement using the Mailable class.
I am using laravel 5.4 scheduler to send an email by embedding(not attaching) images to the view. In the documentation, it has been mentioned that we can pass a $message variable into the view and use
{{ $message->embed('path/to/the/file') }}
in the view file.My code is
//SendUserReport.php ~ (It is a Command class) public function handle(){ \Mail::to($mailList)->send(new GreetReport($data,$subscriber->id)); }
//UserReport.php ~ (It is a Mailable class) public function build(){ $data = $this->mailData; $id = $this->id; return $this->view('mails.reports.user-report', compact('data',)); }
How should I pass the $message variable using the above logic?For the time being, I am able to pass the message variable using the code below without passing the control to the Mailable class (UserReport.php)
//SendUserReport.php ~ (It is a Command class) \Mail::send('mails.reports.user-report',compact('data'), function($message) use ($mailList){ $message->to($mailList)->subject('User Report for '.date('d-m-Y')); })
This code works fine and does well for my need, but I want to implement using the Mailable class.