Illuminate\Database\Eloquent\Builder::applyScopes PHP Méthode

applyScopes() public méthode

Apply the scopes to the Eloquent builder instance and return it.
public applyScopes ( ) : Builder | static
Résultat Builder | static
    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;
    }

Usage Example

 /**
  * Apply the scopes to the Eloquent builder instance and return it.
  *
  * @return \Illuminate\Database\Eloquent\Builder|static 
  * @static 
  */
 public static function applyScopes()
 {
     return \Illuminate\Database\Eloquent\Builder::applyScopes();
 }