} else {
                $query->where(function ($q2) use ($relation_rules, $query_operator) {
                    foreach ($relation_rules as $index => $rule) {
                        if ($rule->operator == 'contains') {
                            $json_operator = $query_operator == 'where' ? 'whereJsonContains' : 'orWhereJsonContains';