Support the ongoing development of Laravel.io →
Views Blade
Last updated 1 year ago.
0

Thanks, what's the best place to put that code?

Last updated 1 year ago.
0

I use view composers which I usually place in app/composers.php and require at the end of app/start/global.php

Last updated 1 year ago.
0

that's normal, because you extends the master page !

Last updated 1 year ago.
0

stephanecoinon said:

I use view composers which I usually place in app/composers.php and require at the end of app/start/global.php

Thanks, i'll try with composers, but anyway, why it does inherit a variable from my master.blade.php? I am overwriting that section in a child view. Why?

Last updated 1 year ago.
0

heihachi88 said:

stephanecoinon said:

I use view composers which I usually place in app/composers.php and require at the end of app/start/global.php

Thanks, i'll try with composers, but anyway, why it does inherit a variable from my master.blade.php? I am overwriting that section in a child view. Why?

In my opinion, it's not the master layout's job to know about SEO or view-specific stuff, it is the controller's or view's job. What I usually do it is either use a view composer, a section or pass it from the controller. It depends on where you need the data (ie which views will consume the data).

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.