I want to do right. Conceived that you can create pages on the site through the admin panel. Created tables pages in the database. Page model and PageController resource PageController . The route is also configured.
In the PageController controller for displaying the page in the show method, I return the view and data for display. It's all clear. Request a page - received.
When I write the admin panel, I’ll use the remaining methods of the PageController controller: store , destroy and others, including index - to display a list of all pages. Thus, one table in the database is one model, one route-resource, one controller.
However, the site has a menu rendered as a separate presentation. The question arises - how to dynamically generate a menu. The index method of the PageController controller PageController busy (for the admin; see above). In addition, my menu is a separate presentation, the child of the parent. There you can’t simply transfer the data there - you will have to send it to each parent species, and this is a bunch of unnecessary code, because the menu is displayed on every page of the site.
That's actually the question - how to get out? How to get data to display this menu? So to say the True Laravel Way.
AdminPageControllerand simplyPageController, so as not to interfere with sections. Then you are released new action games. Secondly, once the menu is generated when a page is displayed, that is, in theshowmethod, then the generation should somehow occur there, with the help of some service. - u_mulder