Apply the scopes to the Eloquent builder instance and return it.

@return Builder|static
183307
public function applyScopes()
	{
		if ( !$this->scopes )
		{
			return $this;
		}

		$builder = clone $this;

		foreach ( $this->scopes as $scope )
		{
			$builder->callScope( function ( Builder $builder ) use ( $scope )
			{
				if ( $scope instanceof Closure )
				{
					$scope( $builder );
				}
				elseif ( $scope instanceof Scope )
				{
					$scope->apply( $builder, $this->getModel() );
				}
			} );
		}

		return $builder;
	}
1052264
public function apply(Builder $builder)
    {
        $this->builder = $builder;

        foreach ($this->filters() as $name => $value) {
            if (! method_exists($this, $name)) {
                continue;
            }

            if (is_array($value) or trim($value)) {
                $this->$name($value);
            } else {
                $this->$name();
            }
        }

        return $this->builder;
    }
100995
protected function makeScope()
    {
        $resource = $this->makeResource();

        if (isset($this->serializer)) {
            $this->fractal->setSerializer($this->serializer);
        }

        return $this->fractal->createData($resource);
    }
688148
protected function listifyScopedQuery()
    {
        $model = new static;

        $model->setListifyConfig('scope', $this->listifyScopeCondition());

        // if set, call a method that may be used to remove global scopes
        // and other automatically active listify-scope breaking clauses
        if (method_exists($this, 'cleanListifyScopedQuery')) {
            $model = $this->cleanListifyScopedQuery($model);
        }

        return $model->whereRaw($this->listifyScopeCondition());
    }
1336900
public function newQueryWithoutScopes()
    {
        $builder = $this->newEloquentBuilder(
            $this->newBaseQueryBuilder()
        );

        // Once we have the query builders, we will set the model instances so the
        // builder can easily access any information it may need from the model
        // while it is constructing and executing various queries against it.
        $builder->setModel($this)->with($this->with);

        $builder->table = $this->getTable();

        return $builder;
    }
531062
public function getChildren()
    {
        $element = $this->current();
        $childContext = $this->elementProcessor->processElementChildren(
            $element,
            $this->contexts[$this->contextMap[$this->key()]]
        );
        return new static($element->childNodes, $childContext, $this->elementProcessor);
    }
878616
public function newQueryWithoutScopes($returnType=Builder::RETURN_TYPE_ELOQUENT)
    {
        $builder = $this->newEloquentBuilder(
            $this->newBaseQueryBuilder(),
            $returnType
        );

        // Once we have the query builders, we will set the model instances so the
        // builder can easily access any information it may need from the model
        // while it is constructing and executing various queries against it.
        return $builder->setModel($this)->with($this->with);
    }
897947
public function getCurrentScope()
    {
        $key = request(Scope::QUERY_NAME);

        return $this->scopes->first(function ($scope) use ($key) {
            return $scope->key == $key;
        });
    }
1161694
public function scopes()
    {
        $scopes = $this->properties->get('scopes');

        if (str_contains($scopes, ',')) {
            $scopes = explode(',', $this->properties->get('scopes'));

            return implode("', '", $scopes);
        }

        return $scopes;
    }
780216
public function registerGlobalScopes($builder)
    {
        foreach ($this->getGlobalScopes() as $identifier => $scope) {
            $builder->withGlobalScope($identifier, $scope);
        }

        return $builder;
    }
284985
public static function scopes()
    {
        return collect(static::$scopes)->map(function ($description, $id) {
            return new Scope($id, $description);
        })->values();
    }
639212
public function get(TreeScope $scope){

        $scopeId = $this->getScopeId($scope);

        if(!isset($this->models[$scopeId])){
            $this->models[$scopeId] = $this->makeModel($scope);
        }

        return $this->models[$scopeId];

    }
842922
public function scopeOfUser(Builder $builder, Model $user): Builder
    {
        return $builder->where('user_type', $user->getMorphClass())->where('user_id', $user->getKey());
    }
1287685
private static function _makeBuilder()
    {
        $builder = new Builder();
        $builder->table = self::getTableName();
        $builder->order = self::getOrder();
        $builder->cls   = get_called_class();
        return $builder;
    }
60266
protected function scaffoldScopes()
    {
        $this->scopes = new Mutable();

        if ($model = $this->model()) {
            $this->fetchModelScopes($model);

            $this->addSoftDeletesScopes($model);
        }

        return $this->scopes;
    }
1279220
public function getScopes()
    {
        if (!isset($this->_scopes)) {
            $this->_scopes = clone $this->getService('com:components.domain.entityset.scope');
        }

        return $this->_scopes;
    }
1094441
public function apply(Builder $builder)
    {
        $this->builder = $builder;

        foreach (array_filter($this->filters()) as $name => $value) {
            if (method_exists($this, $name)) {
                call_user_func_array([$this, $name], [$value]);
            }
        }

        return $this->builder;
    }