FilterBy() 'between' syntax

Hi,

I’m trying to filter a field based on a min and max amount.

I can’t figure out the syntax of the between filter:

$items = $items->filterBy('height', 'between', [5, 10]);
or
$items = $items->filterBy('height', 'between(0,10)')

doesn’t work.

From the docs:

between or .. takes an array as parameter with two parameters; first is the min value, second is the max value

The first syntax example looks good. Do you get a wrong result or an error?

I get the error:

$value is an uncountable object

and some more background:

height is a number field

and this works:

        $height = urldecode($height);
        $range = 2; 

        $items = $items
                     ->filterBy('height','>=', (string)($height-$range))
                     ->filterBy('height','<=', (string)($height+$range));

That’s a bug:

Fixed in upcoming 3.5.7

1 Like