Hi,
In my Laravel app users can send private messages to each other and I want to be able to pass a message instance to my layout so that users can see when they get new messages.
I already passing an instance of the authed user to my layout/views in App::before():
App::before(function($request)
{
App::singleton('shared', function(){
$app = new stdClass;
if (Auth::check()) {
$app->user = Auth::User();
$app->isLogedin = TRUE;
}
else
{
$app->isLogedin = FALSE;
$app->user = FALSE;
}
return $app;
});
$app = App::make('shared');
View::share('shared', $app);
});
and I have tried to add stuff to 'shared' but it doesn't work. I have also tried to pass variables to my layout from the BaseController constructor.
How can I return a database result from a model to my layout every page view?
Woops, I had put the suggestion below but i see you're using shared views already. what exactly do you want to do like a growl message?
Im no expert but I think you can try shared views which for example:
View::share('freelancers', Freelancer::all() );
Every view would have the $freelancers variable available now.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community