It sounds like you want to use a View Composer.
Here's the official documentation on them
Here's a link to an example on Laracast's Forum
Hope this helps!
In 5.1 version you can also resolve a service directly from Blade: https://laravel-news.com/2015/04/laravel-5-1/ (see section "Resolve a service from blade")
thank you for your replies, it seems that i've to read a lot to understand everything ! cuz still new. Thanks again for your efforts.
i solved it using View Composer as you told me, but i've another question if possible :$ now this method is for passing variables to all views or some, is there such a thing but for classes , or Controllers ? so i don't have to include and fetch in each controller.
Thanx a lot
My first thought is having a "Base" or "App" controller, and then having your controllers you want to have the classes/included extend the Base/App controller. Laravel has one that you could build upon (the example there is for Laravel 5) or you can make your own.
If I'm misunderstanding, please let me know.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community