jeudi 2 août 2018

Laravel 5.6 - Can't pass variable to email view

I have setup a mailer in a Laravel 5.6 app but am struggling to pass variables to the view, my welcome.php 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 $user;

    public function __construct()
    {
        $this->user = $user;
    }

    public function build()
    {
        return $this->view('emails.welcome');
    }
}

Any my view looks like this..

Your registered email-id is 

I am calling the email controller after a user is created like this...

$user->save();
Mail::to($user->email)->send(new Welcome($user));

I am getting an error message telling me that undefined variable: user

Where am I going wrong?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KlWaw9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire