in your function apply
1-create different several return depending if $value
or
2-create an array min,max depending with key = $value
and
make a return where >= min and <=max
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Welcome everybody! I'm facing this kind of problem:
I have a filter with request:
/**
* Apply the filter to the given query.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Database\Eloquent\Builder $query
* @param mixed $value
* @return \Illuminate\Database\Eloquent\Builder
*/
public function apply(Request $request, $query, $value)
{
return $query->where('allowable_age_id', '=', $value);
}
/**
* Get the filter's available options.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function options(Request $request)
{
return [
'Two' => '1',
'Two & Up' => '2',
'Three' => '3',
'Three & Up' => '4',
'Four' => '5',
'Four & Up' => '6',
'Five' => '7',
'Five & Up' => '8',
];
}
The values from options: Two, Three, Four, Five I would like to make equal to $value - what I already have, but for values from options: Two & Up, Three & Up, Four & Up, Five & Up I would like to include base value. E.g Three & Up should show records equal to 3 and all above.
Any idea how to solve this kind of problem?
in your function apply
1-create different several return depending if $value
or
2-create an array min,max depending with key = $value
and
make a return where >= min and <=max
Please or to participate in this conversation.