You'll want to initialize and manage the data sent into your views from your controller, etc. Not within the view.
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.
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community