public function newQuery() { $builder = $this->newQueryWithoutScopes(); foreach ($this->getGlobalScopes() as $identifier => $scope) { $builder->withGlobalScope($identifier, $scope); } return $builder; }
/** * Set the constraints for an eager load of the relation. * * @param array $models * * @return void */ public function addEagerConstraints(array $models) { $this->query->whereNested(function (Builder $inner) use($models) { // We will use this query in order to apply constraints to the // base query builder $outer = $this->parent->newQuery(); foreach ($models as $model) { $outer->setQuery($inner)->orWhereDescendantOf($model); } }); }