public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
{
if (strpos($relation, '.') !== false) {
return $this->hasNested($relation, $operator, $count, $boolean, $callback);
}
$relation = $this->getHasRelationQuery($relation);
// If we only need to check for the existence of the relation, then we can
// optimize the subquery to only run a "where exists" clause instead of
// the full "count" clause. This will make the query run much faster.
$queryType = $this->shouldRunExistsQuery($operator, $count) ? 'getRelationQuery' : 'getRelationCountQuery';
$query = $relation->{$queryType}($relation->getRelated()->newQuery(), $this);
if ($callback) {
$query->callScope($callback);
}
return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
}