Is it possible to load views from storage
folder instead from resources\views
?
“laravel storage path url in blade” Code Answer's$currentURL = URL::current(); PHP. $url = URL::to("/"); or use $url = url('/'); PHP. $route = Route::current()->getName(); PHP. $prefix = Request::route()->getPrefix(); PHP.
Laravel offers a simple view that routes to home. Loading a view in the controller is easy. You just need to add `view('viewname')` method while returning from the controller method.
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');
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