F
F
flafy42019-08-23 16:00:12
Laravel
flafy4, 2019-08-23 16:00:12

How to get needed information from DB in any blade file in laravel?

There is an ordinary corporate site where there are classic pages like "Blog", "Home", "Contacts", "About us", and so on and so forth. The footer contains the phone and email of this company. There is also a table in the database - let's call it options, which contains data like: {name => value}.
For example, we take E-mail, and it is stored in the database like this ['email' => '[email protected]']
It is logical that the footer is displayed the same on all pages, how can I correctly display email from the database to the footer on all pages? I understand that in each specific controller method that displays a specific page, it is wrong to duplicate the code with a request to the database.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daria Motorina, 2019-08-23
@flafy4

https://laravel.com/docs/5.8/views#sharing-data-wi...
You create a provider and rummage in it with an email variable, and in the footer you just output

J
JhaoDa, 2019-08-23
@JhaoDa

That's right - carefully read the entire section https://laravel.com/docs/5.8/views
The keywords "attentively" and "all".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question