return view()->first(['partials.sidebar-tempate', 'partials.default-template'], $data);

How to Provide Fallback Views in Laravel
236
3 years ago
0 comments
When returning the view file from the controller, you can provide an array of blade views and it will provide a fallback for when one view is not available. To do so you can make use of the "first()" method which accepts an array of blade views as the first parameter and the data to be passed on as the 2nd parameter.
This is very useful when you have a theme system that by default has a default theme and when you provide a new custom view then the system will make use of the custom view instead of the default one.
Topics:
Frontend
Resource
Average
Average
Support Us
If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️
Leave a reply