spatie / laravel-query-builder

Easily build Eloquent queries from API requests

Home Page:https://spatie.be/docs/laravel-query-builder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Having `orWhereHas` in initial query cancels out filters

7Jhanson opened this issue · comments

I have something like:

QueryBuilder::for(Object::class) ->whereHas('comments')->orWhereHas('relation.comments')->orWhereHas('relation.relationChild.comments') ->allowedFilters($this->setAllowedFilter($this->filters)) ->allowedSorts($this->setAllowedSorts($this->filters)) ->paginate(data_get($options, 'pagination.rowsPerPage'), ['*'], 'page', data_get($options, 'pagination.page'));

when adding the
->orWhereHas('relation.comments')->orWhereHas('relation.relationChild.comments')

the filters don't work anymore, because the package uses whereHas.

Any solutions to make it so I can use orWhereHas and filter at the same time?