Laravel - How to pass data to enable

This way, essentially, all of my views use header.blade.php as I include it in my layout. I need to pass the data to the header on each individual view. So, is there a way to pass data for inclusion only, and not pass data for the header in each view?

+4
source share
2 answers

One option if you are trying to send data only to the included view is to use the composer view . They work even if you try to prepare a performance for@include

view()->composer('header', function($view) {
    $view->with('data', 'some data');
});
+3
source

, :

, , . , , :

@include('view.name', ['some' => 'data'])
+13

All Articles