How to filter NOT IN
value?
#629
-
I can't seem to find it anywhere in the documentation. Basically, I'm asking how I can filter out models based on fields that don't equal the specified value in the URL. Since this package is based on JSON API, I tried using what's in their docs. Still, I couldn't filter in only models whose specified field contains the specified value. For example, I would like to filter users that don't have a /users?filter=not(equals(user_id,1)
/users?filter[user_id]!=1
/users?filter[user_id]=!1
/users?filter[user_id]<>1
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@C-Collamar what you want is either a custom or callback filter. See https://spatie.be/docs/laravel-query-builder/v3/features/filtering#callback-filters , custom filters is the next section below that. You would want to define something like a filter called user_id_not_in and then handle the query logic yourself. It's not as easy as a built-in solution but it's not super difficult either, and it works. |
Beta Was this translation helpful? Give feedback.
@C-Collamar what you want is either a custom or callback filter.
See https://spatie.be/docs/laravel-query-builder/v3/features/filtering#callback-filters , custom filters is the next section below that. You would want to define something like a filter called user_id_not_in and then handle the query logic yourself. It's not as easy as a built-in solution but it's not super difficult either, and it works.