Support the ongoing development of →
Database Eloquent Views
Last updated 9 months ago.

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: L4:


@beanmoss This is just an example. I run like 10 queries and thought it would be nice to commit them in one single transaction?!


i encountered the same problem too. @MichealMi, did you found a solution?


Sign in to participate in this thread!

Full Stack Europe

Your banner here too?

LukasMa lukasma Joined 26 Nov 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.