Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Farshad's avatar

laravel advance where query builder

I have an advance where query and need to set operation for that like below but it's not working

$query->where(function($q) use($filter, $field){
        $this->applyFilter($q, $filter, $field);
}, $filter->operation);

the $filter->operation could be one of or | and how I could implement this know it just and the query

0 likes
1 reply
Farshad's avatar
Farshad
OP
Best Answer
Level 1

I found the way to handle this like below where accept four parameter and the last one is boolean and the operator

$query->where(function($q) use($filter, $field){
        $this->applyFilter($q, $filter, $field);
}, null, null, $filter->operation);

Please or to participate in this conversation.