覆盖密码重置模板时出现错误Laravel 5.3

时间:2016-08-31 19:14:04

标签: php laravel email laravel-5 laravel-5.3

您好我刚刚开始研究laravel 5.3并很快遇到了这个问题。与5.2不同,我们有硬编码的电子邮件或一些自定义包,这里我们只限于一个模板。

首先,我已更新用户模型以包含

public function sendPasswordResetNotification($token)
{
    $this->notify(new ResetPasswordNotification($token));
}

然后我有一个名为ResetPasswordNotification的通知文件,里面有一个

 public function toMail()
    {
        return (new MailMessage)
            ->line([
                'You are receiving this email because we received a password reset request for your account.',
                'Click the button below to reset your password:',
            ])
            ->action('Reset Password', url('password/reset', $this->token))
            ->line('If you did not request a password reset, no further action is required.');
    }

但我希望包含自定义电子邮件模板视图,并将数据发送到这些视图,就像我们之前的做法一样。现在要在新的laravel中恭维旧式,我们必须像这样采用它。

 return (new MailMessage)
            ->view('emails.templates.layout5')
            ->data([
                'pageTitle' => 'Password Reset',
                'logo' => $logo,
                'topMenu' => 'TOP MENU',
                'mainTitle' => 'Verify email to',
                'subTitle' => 'Reset Your Password',
                'image' => 'largeimg.png',
                'content' => $content,
            ]);

但是当我这样做时,我收到错误

ErrorException in MailChannel.php line 44:
Trying to get property of non-object

0 个答案:

没有答案