Following on from a previous question, I have an email controller set up to correctly pass user data to the view. I am now trying to modify it so I can pass some custom data instead. My controller looks like this...
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class Welcome extends Mailable
{
use Queueable, SerializesModels;
public $email_data;
public function __construct($email_data)
{
$this->email_data = $email_data;
}
public function build()
{
return $this->view('emails.welcome')->with(['email_data' => $this->email_data]);
}
}
And I am sending the email like this...
/* Create Data Array For Email */
$email_data = array(
'first_name'=>'John',
'last_name'=>'Doe',
'email'=>'john@doe.com',
'password'=>'temp',
);
/* Send Email */
Mail::to($user->email)->send(new Welcome($email_data));
Is this correct? When I try using this method it does not seem to be passing the data through to the email template. How can I then access this data within the view?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OBSutG
via IFTTT
Aucun commentaire:
Enregistrer un commentaire