Solved!!
There are two ways of adding new paths for views in Laravel:
view()->addLocation('/modules/XXXXModule/core/views'); view()->addLocation('/modules/YYYYModule/core/views'); The above will work but if you have a list.blade.php view in each of the folders, if you use this:
return view('list'); it will always return the one it finds in the location registered first, which in this case would be for XXXXModule. So while it works it has its drawbacks for your modular structure.
view()->addNamespace('XXXXModule', '/modules/XXXXModule/core/views'); view()->addNamespace('YYYYModule', '/modules/YYYYModule/core/views'); The above will register each path in a different namespace, so if you have two view files with the same name (i.e. list.blade.php) but are part of two different modules you can access them as following:
// for XXXXModule return view('XXXXModule::list');
// for YYYYModule return view('YYYYModule::list'); This way you have no more conflicts of location.
Also on your service provider boot method you can do this;
$this->loadViewsFrom(['path1', 'path2'], 'namespace');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community