【发布时间】:2022-01-11 07:03:21
【问题描述】:
View [cart] not found. {"exception":"[object] (InvalidArgumentException(code: 0): View [cart] not found. at C:\\wamp\\www\\projects\\BBT\\vendor\\laravel\\framework\\src\\Illuminate\\View\\FileViewFinder.php:137)
我创建了一个notification 并尝试使用cart.blade.php 作为邮件模板,如下所示。但是我收到了上述错误。我已经尝试通过此链接清除缓存:https://stackoverflow.com/questions/17913929/laravel-view-not-found-exception
namespace App\Notifications;
class CartExpiryNotification extends Notification
{
public function toMail($notifiable)
{
return (new MailMessage)
->view('cart', ['cartTemplate' => 'cartTemplate']);
}
}
cart.blade.php
{{$cartTemplate}}
cart.blade.php 存在于路径 C:\wamp\www\projects\BBT\vendor\laravel\framework\src\Illuminate\Notifications\resources\views\cart.blade.php 中。
【问题讨论】:
-
视图应该放在
/resources/views文件夹中,而不是/vendor/...文件夹中 -
@brombeer 好的。现在我将
cart.blade.php移动到文件位置C:\wamp\www\projects\BBT\resources\views\vendor\notifications\cart.blade.php。仍然显示相同的错误 -
view('cart' ...期望刀片文件驻留在/resources/views文件夹中 - 而不是其中的任何子文件夹。可能想阅读Creating & Rendering Views
标签: php laravel exception notifications laravel-8