Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Blade pass array data to multiple extends

I've searched for this on internet alot, but wasnt able to find answers. I'm using Laravel 5 and I've little issue with blade templating as in my project I need sometime to do multiple extends and I need to pass all data from one layout to all master layouts "extends"

Nested page example :

@extends('layouts.full', ['var' => 'key'])

@section('page')
   page content here
@stop

layouts/full.blade.php example

@extends('app', ['need to pass same data here too'])

@section('content')
   @yield('page')
@stop

and app.blade.php is just main html stuff

And I wanted to ask is there possibility to pass same vars without setting global variable like?

@extends('layouts.full', $data = [])
like image 955
chaot1x Avatar asked Feb 12 '26 10:02

chaot1x


1 Answers

I think this might help you : https://laravel.com/docs/5.2/blade#service-injection

like image 147
Вилислав Венков Avatar answered Feb 15 '26 00:02

Вилислав Венков



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!