Is dificult for explain but i want to try. I have index.blade.php. In index.blade.php i have @include('header.blade.php') and @include('footer.blade.php'). The content inside index.blade.php is a list of users from bbdd. This is ok and work well. Now, in header.blade.php, I have a icon with alerts and show the last 5 alerts. But this header.blade.php is common content from all site but inside the alert box i need load the last alerts from table alerts of bbdd. How I could load inside alert box this content. I could create a function in basecontroller with this action, but ¿how could i call it in the template header.blade.php?
In your BaseController you can use this:
public function __construct () {
$ alerts = Alert::where()->get(); // get alerts from database
View::share ('alerts', $alerts);
}
Using share() will make that available in all views.
This didn't work for me... what am I missing??? :(
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community