In laravel I can do something like this:
$users = App\User::with(['posts' => function ($query) { $query->where('title', 'like', '%first%'); }])->get();
but now I'm using laravel-make-repository, and I want to do eager loading folders with query:
$folders = $this->folderRepository->where('parent_id', null)->with(['Children' => function($q) => { // my query here }])->get();
When I try the code above I get this error:
TypeError: Argument 1 passed to Illuminate\Database\Eloquent\Builder::parseWithRelations() must be of the type array, object given,
How can I do eager loading with additional query just like laravel? and do I need to change my BaseRepository.php or not?
Any help ?
In laravel I can do something like this:
$users = App\User::with(['posts' => function ($query) { $query->where('title', 'like', '%first%'); }])->get();
but now I'm using laravel-make-repository, and I want to do eager loading folders with query:$folders = $this->folderRepository->where('parent_id', null)->with(['Children' => function($q) => { // my query here }])->get();
When I try the code above I get this error:
TypeError: Argument 1 passed to Illuminate\Database\Eloquent\Builder::parseWithRelations() must be of the type array, object given,
How can I do eager loading with additional query just like laravel? and do I need to change my BaseRepository.php or not? Any help ?