Answer the question
In order to leave comments, you need to log in
How to properly build architecture in MVC?
Let's say we have such a site - it has a top menu that changes after a page refresh. This menu is written in the main (master) view. So, in theory, so that the information in the menu is updated every time, every time in each controller (let it be a list of comments, even a list of friends) I will need to transfer this information, which is convenient, can I somehow get out? The project is being done on Laravel 5.1. And yet, there is one feature, the blade templating engine is not used (customer's requirement). I hope I explained clearly :)
Answer the question
In order to leave comments, you need to log in
For starters, blade is just a wrapper around php, and not using it gives you even more options than using it, although it doesn't look as pretty.
Then you have two options:
1) To do as DieZz said , view->share('key', 'value') it is best to register it in the controller from which all other controllers will then inherit.
2) Define a class for managing the menu and inject it into the view itself. Next is the option with a blade, how to do it without a blade, I hope you figure it out
@inject('metrics', 'App\Services\MetricsService')
<div>
Monthly Revenue: {{ $metrics->monthlyRevenue() }}.
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question