Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering with "or" condition #3

Closed
LIQRGV opened this issue Nov 14, 2019 · 1 comment
Closed

Allow filtering with "or" condition #3

LIQRGV opened this issue Nov 14, 2019 · 1 comment
Labels
good first issue Good for newcomers

Comments

@LIQRGV
Copy link
Owner

LIQRGV commented Nov 14, 2019

We should able transform this query param:
x_model?filter[x|y][is]=1&filter[z][in]=1,2,3

into this filter

...... where (x = 1 or y = 1) and z in (1,2,3);
@LIQRGV LIQRGV added the good first issue Good for newcomers label Nov 15, 2019
@PMessinezis
Copy link
Contributor

I would like to give it a try. I am thinking of the following approach :

  1. in the constructor of FilterStruct : check if "|" is included in the fieldName, and if yes, then explode it into an array

  2. in apply() method of FilterStruct : if fieldName is an array, then create a $subquery closure applying where/orWhere for the first and subsequent items in the fieldName array and then return $object->where($subquery)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants