How to loop through menu items in main layout

Posted 11 months ago by pickab00

I have a front.blade.php in my layouts folder and it contains the nav bar. I was wondering how I could take my menu items from categories table and display it in my nav inside the main blade layout.

Also, Some of the categories uses the same template to display their related posts. Eg. sports displays only sports data. And technology displays only technology related data. But both of them uses the same template. So what would be wise here? Here is my idea I have so far:

For Route:

Route::get('/{category_name}', '[email protected]');
//This will redirect the categories to the template which handles the above sports and technology

But doing so, what about my other categories which uses a different template? How will I tell laravel which categories I want to use the same template and for others, use some other template.

The thing that confuses me is, if i foreach through the categories, It will contain a column named link which will be the href="" value. But using a foreach will output all the values in categories and therefore I can not tell laravel if it is sports & technology, use this template and if it is songs use another template. How do I proceed with this?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.