cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x] Add `includes` and `doesnt_include` conditions and modifiers

Open ryanmitchell opened this issue 6 months ago • 6 comments

This is a second go at this and is an alternative to / replaces https://github.com/statamic/cms/pull/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 https://github.com/statamic/ideas/issues/910

ryanmitchell avatar Feb 08 '24 18:02 ryanmitchell

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).

afonic avatar Feb 10 '24 09:02 afonic

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 avatar Mar 05 '24 18:03 robdekort

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.

robdekort avatar Mar 05 '24 18:03 robdekort

do you reckon this will make the cut someday

More than likely, but not 100% sure.

jasonvarga avatar Mar 06 '24 18:03 jasonvarga

Gotcha. Thanks Jason.

robdekort avatar Mar 06 '24 18:03 robdekort

Nice! This will close https://github.com/statamic/ideas/issues/910

jacksleight avatar Apr 05 '24 09:04 jacksleight