jason-guru / laravel-make-repository

A simple package for adding make:repository command to Laravel 5 and above
Other
59 stars 32 forks source link

Eager loading with additional query #2

Closed mahdi-mk closed 4 years ago

mahdi-mk commented 4 years ago

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 ?