If I want to load a view from a custom folder at run time, I’m not sure how to do it.
I know I can add a permanent alternative to my view to the paths value in the config/view.php file. However I have tried adding to this at run time just before calling with no success
eg.
Config::set(['views.paths' => 'my/custom/path']);
return view('bladeinmycustompath');
this doesnt work. I have also tried using a full path to no avail.
Is there an easy way to render a specific blade file or add a custom path at run time.
I know I can simply add the path to the view.php file at design time but I dont want tot do this.
>Solution :
use Illuminate\Support\Facades\View;
public function loadCustomView()
{
// Add the custom view path for this request
View::addLocation('/path/to/your/custom/views');
return view('customview'); // The view name without the .blade.php extension
}