/**
* Add a relationship count condition to the query.
*
* @param string $relation
* @param string $operator
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder
*/
public function has($relation, $operator = '>=', $count = 1)
{
$instance = $this->model->{$relation}();
$query = $instance->getRelationCountQuery($instance->getRelated()->newQuery());
$this->query->mergeBindings($query->getQuery());
return $this->where(new Expression('(' . $query->toSql() . ')'), $operator, $count);
}