trait HasGlobalScopes (View source)

Methods

static void
bootHasGlobalScopes()

Boot the has global scopes trait for a model.

static array
resolveGlobalScopeAttributes()

Resolve the global scope class names from the attributes.

static mixed
addGlobalScope(Scope|Builder<static>): mixed|string $scope, Scope|Builder<static>): mixed|null $implementation = null)

Register a new global scope on the model.

static void
addGlobalScopes(array $scopes)

Register multiple global scopes on the model.

static bool
hasGlobalScope(Scope|string $scope)

Determine if a model has a global scope.

static Scope|Builder<static>): mixed|null
getGlobalScope(Scope|string $scope)

Get a global scope registered with the model.

static array
getAllGlobalScopes()

Get all of the global scopes that are currently registered.

static void
setAllGlobalScopes(array $scopes)

Set the current global scopes.

array
getGlobalScopes()

Get the global scopes for this class instance.

Details

static void bootHasGlobalScopes()

Boot the has global scopes trait for a model.

Return Value

void

static array resolveGlobalScopeAttributes()

Resolve the global scope class names from the attributes.

Return Value

array

static mixed addGlobalScope(Scope|Builder<static>): mixed|string $scope, Scope|Builder<static>): mixed|null $implementation = null)

Register a new global scope on the model.

Parameters

Scope|Builder<static>): mixed|string $scope
Scope|Builder<static>): mixed|null $implementation

Return Value

mixed

Exceptions

InvalidArgumentException

static void addGlobalScopes(array $scopes)

Register multiple global scopes on the model.

Parameters

array $scopes

Return Value

void

static bool hasGlobalScope(Scope|string $scope)

Determine if a model has a global scope.

Parameters

Scope|string $scope

Return Value

bool

static Scope|Builder<static>): mixed|null getGlobalScope(Scope|string $scope)

Get a global scope registered with the model.

Parameters

Scope|string $scope

Return Value

Scope|Builder<static>): mixed|null

static array getAllGlobalScopes()

Get all of the global scopes that are currently registered.

Return Value

array

static void setAllGlobalScopes(array $scopes)

Set the current global scopes.

Parameters

array $scopes

Return Value

void

array getGlobalScopes()

Get the global scopes for this class instance.

Return Value

array

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.