我有一个 laravel 项目,其中有以下视图:
'ProjectName\custom\subfolder\resources\views\theview.blade.php'
我怎样才能返回这个视图?
我尝试使用view('theview')这不起作用,因为它只适用于内部的视图:
'ProjectName\resources\views'
如何从外部资源\视图文件夹返回视图?
我有一个 laravel 项目,其中有以下视图:
'ProjectName\custom\subfolder\resources\views\theview.blade.php'
我怎样才能返回这个视图?
我尝试使用view('theview')这不起作用,因为它只适用于内部的视图:
'ProjectName\resources\views'
如何从外部资源\视图文件夹返回视图?
在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('my-view')
,但是重复的名称(或名称冲突)将导致 Laravel 根据paths
键中指定的顺序选择视图。
绝对到位!就在 Laravel 6.0 中
'paths' => [
resource_path('views'),
resource_path('views/canaanmodels'),
],
我的视图位于“views”floder 内的文件夹“ canaanmodels ”中,而realpath现在已被替换为resource_path并且没有更多的base_path ...希望它能帮助某人!干杯