A
A
Alexey Nikolaev2019-10-09 16:54:19
Laravel
Alexey Nikolaev, 2019-10-09 16:54:19

What is the best way to make common properties for all views?

Good day.
Let's say we display the latest events \ articles in the sidebar in the menu. To do this, you need to throw in the controller, for example, `$latestEvents`. The latest events should be on each page, which leads to a head-on solution: in each controller, throw `$latestEvents` into the view.
Obviously this is a bad decision. And obviously this must be a fairly well-known case. Of course, I can cycle in the base controller, or create a macro that would mix properties from the config into each view, but perhaps there is a pattern \ good package \ common solution?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2019-10-09
@Heian

Search and documentation for suckers, right? From fresh -  How to pass the model to all views with __construct?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question