protected function queryHasRelations($query, $hasRelations = [])
    {
        $hasRelations = $hasRelations ?: $this->hasRelations;

        foreach ($hasRelations as $relation => $operatorCount) {
            list($operator, $count) = $operatorCount;
            $query->has($relation, $operator, $count);
        }

        return $query;
    }