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