A
A
adam_carraway2018-12-30 19:52:00
Laravel
adam_carraway, 2018-12-30 19:52:00

How to correctly pass data to layouts?

Good evening, tell me correctly, I pass data to layouts (all pages). Now I do it through the AppServiceProvider, in the same way:

view()->share(['com_news'=> $com_news,'count_category'=>$count_category,'filter_name'=>$filter_name]);

What other ways are there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
netrox, 2018-12-30
@netrox

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question