R
R
Roman2022-01-15 16:48:26
Laravel
Roman, 2022-01-15 16:48:26

Laravel how to implement menu generation for whole template in one go?

I have a website template. In the header of the site menu.

In the database, a table with a menu (id, name, description)
AND a table with static pages (id, menu_id, name, position, title, body)

Several controllers work with this template.
How to display the menu in the header of the site correctly?

Initially, I thought about making a request to the database with getting the right pages from the right menu. And already generate in the blade menu.

But if there are 10 controllers? it's the same in everyone.
It doesn't seem right. You need to somehow create a menu generation for the entire template in one place.

I hope I have explained my idea clearly. Tell me how to do it?

To display the menu, I need to pass the related

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question