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

[5.x] Add includes and doesnt_include conditions and includes modifier #9491

Open
wants to merge 4 commits into
base: 5.x
Choose a base branch
from

Conversation

ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented Feb 8, 2024

This is a second go at this and is an alternative to / replaces #8357

This PR adds an includes modifier and tag condition, as well as a doesnt_include tag condition. The Modifier is intentionally a loose comparison, so if any of the values in needle are found it counts as a match. This is to mirror how whereJsonContains() on the eloquent side.

Potentially an includes_all modifier could be added for a strict comparison (or the naming of this could be changed to includes_any).

Closes statamic/ideas#910

@ryanmitchell ryanmitchell changed the title [4.x] Add includes condition and modifier [4.x] Add includes and doesnt_include conditions and modifiers Feb 8, 2024
@ryanmitchell ryanmitchell changed the title [4.x] Add includes and doesnt_include conditions and modifiers [4.x] Add includes and doesnt_include conditions and includes modifier Feb 8, 2024
@afonic
Copy link

afonic commented Feb 10, 2024

Good job! This is very useful and will solve not being able to filter by any field that gets saved by an array (like multiple select, checkboxes etc).

@robdekort
Copy link
Contributor

This is very useful, and seems to work like a charm. I ran into a Statamic limitation and @afonic pointed me to your PR Ryan. Thanks both.

@robdekort
Copy link
Contributor

Jason do you reckon this will make the cut someday and I can patch it in? Otherwise I'll work on a query scope instead.

@jasonvarga
Copy link
Member

do you reckon this will make the cut someday

More than likely, but not 100% sure.

@robdekort
Copy link
Contributor

Gotcha. Thanks Jason.

@jacksleight
Copy link
Contributor

Nice! This will close statamic/ideas#910

@ryanmitchell ryanmitchell changed the base branch from 4.x to 5.x May 10, 2024 10:04
@ryanmitchell ryanmitchell changed the title [4.x] Add includes and doesnt_include conditions and includes modifier [5.x] Add includes and doesnt_include conditions and includes modifier May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tag conditions for whereJsonContains and whereJsonDoesntContain
5 participants