dimanche 3 mars 2019

Variables are not passed in the email template

I'm having this method in my controller

public function update(UserUpdateRequest $request)
{
        $request->user()->update([
            'name' => $request->username,
        ]);

        Mail::to($request->user())->send(
            new UserUpdated( $request->user() )
        );

        return redirect()->route('account.index');
}

So when the user updates the username an email is send

public $user;

/**
 * Create a new message instance.
 *
 * @return void
 */
public function __construct(User $user)
{
    $this->user = $user;
}

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    return $this->markdown('emails.user.updated');
}

And this is the email template

Hi ,

We would like to inform you that your username has been updated successfully. 

If this action wasn't done by you, you need to contact with our support.

But this is throwing an exception in the queues

ErrorException: Undefined variable: user in /storage/framework/views/

Any ideas what I'm doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire