protonemedia / laravel-cross-eloquent-search

Laravel package to search through multiple Eloquent models. Supports sorting, pagination, scoped queries, eager load relationships and searching through single or multiple columns.
https://protone.media/blog/search-through-multiple-eloquent-models-with-our-latest-laravel-package
MIT License
1.1k stars 80 forks source link

Eager Load Relationships with Scope #70

Closed ukeshdhusu closed 1 year ago

ukeshdhusu commented 2 years ago

Can we use eager load relationships with scope like

Search::add(Blog::with([ 'comment' => function($query) { $query->published() } ]), ['title', 'comment.body' ] )
    ->get('guitar');
pascalbaljet commented 1 year ago

Yes.