L
L
lolrofl012018-06-16 10:07:19
Laravel
lolrofl01, 2018-06-16 10:07:19

How to correctly pass a variable in laravel to all templates?

I don't understand the documentation on this point. There are a lot of solutions and not a single detailed one. A banal problem: a record from the database is displayed in the footer file. The whole template is built on blade. So, there are many pages on the site, but there is only one footer. How is it easier and more correct to get this record from the database once and so that it is transferred to the footer, regardless of which page on the site is open?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Barmunk, 2018-06-16
@lolrofl01

To do this, use the view composer https://scotch.io/tutorials/sharing-data-between-v...

V
Victor, 2018-06-16
@v_decadence

https://laravel.com/docs/5.6/views#view-composers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question