Illuminate\Database\Eloquent\Model::addGlobalScope PHP Method

addGlobalScope() public static method

Register a new global scope on the model.
public static addGlobalScope ( Illuminate\Database\Eloquent\Scope | Closure | string $scope, Closur\Closure $implementation = null ) : mixed
$scope Illuminate\Database\Eloquent\Scope | Closure | string
$implementation Closur\Closure
return mixed
    public static function addGlobalScope($scope, Closure $implementation = null)
    {
        if (is_string($scope) && !is_null($implementation)) {
            return static::$globalScopes[static::class][$scope] = $implementation;
        }
        if ($scope instanceof Closure) {
            return static::$globalScopes[static::class][spl_object_hash($scope)] = $scope;
        }
        if ($scope instanceof Scope) {
            return static::$globalScopes[static::class][get_class($scope)] = $scope;
        }
        throw new InvalidArgumentException('Global scope must be an instance of Closure or Scope.');
    }
Model