我最近从Laravel 5.6升级到5.7。
我通过添加新变量来更新降价通知视图模板,如下所示:
$mailMessage = (new MailMessage)
->from('no-reply@xyz.com', 'xyz company')
->subject('xyz subject')
->markdown('emails.news-alert', [
'url' => 'www.xyz.com',
'articles' => $this->articles
]);
return $mailMessage;
在视图emails.news-alert
中,我有以下内容:
<a href='{{ $url }}'>{{ $url }}</a>
该通知已发送到laravel队列,但一直处于失败状态。当我检查failed_jobs
表时,异常记录为:
ErrorException: Undefined variable: url in storage\framework\views\b3a65990593f44f6fa9a99a22b876723bd86dd3b.php:38
我尝试清除缓存,但仍然出现此错误:
php artisan view:clear
php artisan cache:clear
有任何想法为什么会这样?
奇怪的是,如果我按如下所示预览通知,它会显示正常:
Route::get('/notification', function () {
$articles = App\Article::paginate(2);
$message = (new App\Notifications\NewsNotification($articles))->toMail(Auth::user());
$markdown = new Markdown(view(), config('mail.markdown'));
return $markdown->render('emails.news-alert', $message->data());
});
答案 0 :(得分:0)
重新启动队列:工作人员似乎已将其修复。