laravel-json-api / laravel

JSON:API for Laravel applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Nesting Filters

DellanX opened this issue · comments

Hi,

I need to be able to combine two filters via an AND or an OR operation, but don't see a way to do this in the documentation.
Is this currently possible with this library?

For example, I would like to able to grab all dates within a range of time, or that are in a draft state.
Something such as:

(start < desiredEnd && end < desiredStart) || (!published)

Right now, I might have an idea, but it feels very hackish.
It seems to me like all filters are currently combined by an AND operation. I don't see a way to implement an OR operation.

This package isn't opionated about how filters are implemented. That's because the JSON:API spec leaves it up to implementations as to how to implement filters - it just reserves the filter query parameter for this use.

We provide filters that map directly to things that the Laravel query builder provides. But we aren't saying you have to use them.

You can implement your own filtering logic by writing your own filters:
https://laraveljsonapi.io/docs/3.0/schemas/filters.html#writing-filters

What you're suggesting could be done via your own filter. We'd never provide that from this package because it's too specific to your use case.