laravel eager loading closure

Solutions on MaxInterview for laravel eager loading closure by the best coders in the world

showing results for - "laravel eager loading closure"
Valentina
05 Aug 2019
1// with load
2return $packageItem->load(['answers' => function ($query) use ($userId) {
3            $query->where('user_id', $userId);
4        }]);
5
6// with with ;)
7Entry::with(array(
8    'foo' => function($query) use ($id) {
9        $query->where('user_id', $id);
10    },
11    'author',
12    'lastModifiedBy'
13))->...;
14
15
16$x = $widget->objGallery->galleryItems()->with(array('captions' => 
17      function($query){ $query->where('locale', $id );
18     }))->get();