Answer the question
In order to leave comments, you need to log in
How to pass a variable to all View laravel at once?
How to pass the variable I need so that it is available in all views?
Now I transfer only through the controllers of each view separately, and I over immediately in all so that it can be seen.return view('home')->with('role',$role);
Answer the question
In order to leave comments, you need to log in
View Composers
AppServiceProvider
But judging by the name of the variable, you don't need to pass anything to the templates, but use the can directive
You can make a global array like
$view_data = [];
$this->view_data['var_1'] = $data;
return view('view_file', $this->view_data);
Use this construction everywhere and get an array with data at the output and process them on the view
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question