我有一个 laravel 项目,我有以下 View :
'ProjectName\custom\subfolder\resources\views\theview.blade.php'
如何返回这个 View ?
我尝试使用 view('theview') 但它不起作用,因为它只适用于内部 View :
'ProjectName\resources\views'
如何从 resources\views 文件夹外返回 View ?
最佳答案
在 config/view.php
配置文件中,添加到 paths
键:
<?php
return [
'paths' => [
realpath(base_path('resources/views')),
realpath(base_path('custom/subfolder/resources/views')),
],
'compiled' => realpath(storage_path('framework/views')),
];
您可以以通常的方式加载您的 View ,例如 view('my-view')
,但是重复的名称(或名称冲突)将导致 Laravel 根据指定的顺序选择 View 在 paths
键中。
关于来自不同文件夹的 Laravel View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51322392/