I have a laravel project where I have the following view:
'ProjectName\custom\subfolder\resources\views\theview.blade.php'
How can I return this view?
I tried to use view('theview') That did not work because that only works on views inside:
'ProjectName\resources\views'
How can I return the view from outside theresources\views folder?
Inside the config/view.php
config file, add to the paths
key:
<?php
return [
'paths' => [
realpath(base_path('resources/views')),
realpath(base_path('custom/subfolder/resources/views')),
],
'compiled' => realpath(storage_path('framework/views')),
];
You can load your views in the usual way, eg view('my-view')
, however duplicate names (or name collisions) will result in Laravel selecting the view based on the order specified in the paths
key.
Absolutely spot on! Just in the Laravel 6.0
'paths' => [
resource_path('views'),
resource_path('views/canaanmodels'),
],
Where my view is in the folder 'canaanmodels' which is inside 'views' floder and the realpath has now been replaced with resource_path and there is no more base_path... Hope it gonna help someone! Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With