Open c-gross opened 1 year ago
@c-gross Hello! This filter uses WHERE BETWEEN sql command. This one won't work without both values. You may create custom filter like this:
class WhereMinMax extends BaseHttpEloquentFilter
{
public function run(Builder $builder): Builder
{
$params = $this->getHttpValue();
if (isset($params['min'])) {
$builder->where($this->column, '>', $params['min']);
}
if (isset($params['max'])) {
$builder->where($this->column, '<', $params['max']);
}
return $builder;
}
}
It works correctly with TD::FILTER_NUMBER_RANGE
The new Orchid 14 $allowedFilters configuration has an issue: Using a table filter TD::FILTER_NUMBER_RANGE and $allowedFilters WhereBetween only works when a min and max value is given.
If only one value is set (min or max) it will run in an SQL error. ?filter[stock][max]=5
SQLSTATE[HY093]: Invalid parameter number select count(*) as aggregate from
products
wherestock
between 5 and ?Tested with Orchid 14.2.1