/** * Merge the "wheres" from a relation query to a has query. * * @param \Nova\Database\ORM\Builder $hasQuery * @param \Nova\Database\ORM\Relations\Relation $relation * @return void */ protected function mergeWheresToHas(Builder $hasQuery, Relation $relation) { $relationQuery = $relation->getBaseQuery(); $hasQuery = $hasQuery->getModel()->removeGlobalScopes($hasQuery); $hasQuery->mergeWheres($relationQuery->wheres, $relationQuery->getBindings()); $this->query->mergeBindings($hasQuery->getQuery()); }
/** * Merge the "wheres" from a relation query to a has query. * * @param \Nova\Database\ORM\Builder $hasQuery * @param \Nova\Database\ORM\Relations\Relation $relation * @return void */ protected function mergeWheresToHas(Builder $hasQuery, Relation $relation) { // Here we have the "has" query and the original relation. We need to copy over any // where clauses the developer may have put in the relationship function over to // the has query, and then copy the bindings from the "has" query to the main. $relationQuery = $relation->getBaseQuery(); $hasQuery = $hasQuery->getModel()->removeGlobalScopes($hasQuery); $hasQuery->mergeWheres($relationQuery->wheres, $relationQuery->getBindings()); $this->query->mergeBindings($hasQuery->getQuery()); }