You should pass $data
to closure by reference:
DB::transaction(function() use ($user, &$data)
Why do you need to use Transaction? I think a better implementation for this is:
View::composer(array('profile','dashboard'), function($view)
{
$view->with('count', User::count());
});
L5: http://laravel.com/docs/5.0/views#view-composers L4: http://laravel.com/docs/4.2/responses#view-composers
@beanmoss This is just an example. I run like 10 queries and thought it would be nice to commit them in one single transaction?!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community