Support the ongoing development of Laravel.io →
posted 10 years ago
Blade
Last updated 2 years ago.
0

You'll want to initialize and manage the data sent into your views from your controller, etc. Not within the view.

Last updated 2 years ago.
0

I've seen a trick to do it once so yes it's possible but as Shawn said: You should'nt do it. Using views (templates) is about seperartion of concerns and initializing variables should be done outside of a view.

Last updated 2 years ago.
0

Also, you can take a look at view composers.

Last updated 2 years ago.
0

What if a common file is used in whole system. And a parameter we have to pass on some pages. In that case we have to declare that variable in all controllers used in system which is not a way.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ahhmarr ahhmarr Joined 1 Feb 2014

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.