/**
* Add the "has" condition where clause to the query.
*
* @param \Illuminate\Database\Eloquent\Builder $hasQuery
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
* @param string $operator
* @param int $count
* @param string $boolean
* @return \Illuminate\Database\Eloquent\Builder|static
*/
protected function addHasWhere(Builder $hasQuery, Relation $relation, $operator, $count, $boolean)
{
$hasQuery->mergeModelDefinedRelationConstraints($relation->getQuery());
if ($this->shouldRunExistsQuery($operator, $count)) {
$not = $operator === '<' && $count === 1;
return $this->addWhereExistsQuery($hasQuery->toBase(), $boolean, $not);
}
return $this->whereCountQuery($hasQuery->toBase(), $operator, $count, $boolean);
}