Answer the question
In order to leave comments, you need to log in
How to organize the output of the same information for different pages in laravel?
Probably the title was not clear enough. The point is this. I have a view template, traditionally divided into sections. There is a footer.php file, which, of course, is responsible for the footer. The footer displays information from the database. There are many pages on the site and the footer connects to all of them. Each page is rendered by a separate controller. The question is, is it really necessary to do the same thing in each controller - to make a selection from the database and transfer an array with data to the view, or can this matter be automated somehow? I really don't want to paste the same code into every controller.
Answer the question
In order to leave comments, you need to log in
Pass the data to all templates in the service provider. In the boot method write view()->share(variable_name, variable_value);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question