Reputation: 435
Is it possible to load views from storage
folder instead from resources\views
?
Upvotes: 5
Views: 6911
Reputation: 4049
Yes, you have a couple of choices.
Open up config/view.php
and add your new path to the paths
array:
'paths' => [
storage_path(),
realpath(base_path('resources/views')),
],
Laravel will return whichever view that matches first, so be sure to sort the paths accordingly.
Open up app/Providers/AppServiceProvider.php
and add your new view namespace:
public function boot()
{
$this->loadViewsFrom(storage_path(), 'custom_name');
}
With this you can access the views with a prefix like custom_name
:
return view('custom_name::home');
Upvotes: 20
Reputation: 3424
Yes it is possible.
Just config your view.php file like this
<?php
return
['paths' => [realpath(base_path('storage/views')),],
'compiled' => realpath(storage_path('framework/views')),
];
?>
Upvotes: 0