Reputation: 120
I have layout called app.blade.php
and in views I extends that layout.
How can I pass data from pivot table in master layout to be on every page.
Upvotes: 1
Views: 827
Reputation: 954
You could pass the variable into the blade @extend
tag like this:
@extends(' <<Your file name>> ', ['value' => $value])
Upvotes: 1
Reputation: 163768
You can add View::share()
to service provider to share data with all views:
public function boot()
{
View::share('key', 'value');
}
Or you could create view composer.
View composers are callbacks or class methods that are called when a view is rendered. If you have data that you want to be bound to a view each time that view is rendered, a view composer can help you organize that logic into a single location.
Upvotes: 2