Level 13
You could use a view composer attached to your layout file.https://laravel.com/docs/5.6/views#view-composers
1 like
I work on e-commerce website ,in my master page layout all categories are shown in header section the issue is i add master page attributes in all routes . is their any way i add these attributes any where else only one time not for all routes.
//////////////////////Header//////////////////////////////////////
$all_categories= Category::where('published',1)->get();
$nav_categories=Category::with('sub_category','ribbon')->where([['published',1],['shown_nav',1],['parent_id',null]])->get();
////////////////////////////////\\
these lines of code used in every action
You could use a view composer attached to your layout file.https://laravel.com/docs/5.6/views#view-composers
Please or to participate in this conversation.