Answer the question
In order to leave comments, you need to log in
LaravelViewServiceProvider?
there is a ViewServiceProvider in which there is View::composer('path to the template', a function that receives data from the database and returns it to via $view->with()), it so happened that this view is used twice on one page -> there are two identical requests to the database. Is there any way to solve this? For example, make a request not in the view itself, but BEFORE it and after passing the finished data in order to then pass it to the view through the same $view-> with ()
Answer the question
In order to leave comments, you need to log in
Crutch on static
View::composer('dashboard', function ($view) {
static $result;
if(!$result) {
$result = getSomeData();
}
$view->with($result);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question