你好,我刚刚开始研究 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