trait HasGlobalScopes

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|Closure|string $scope, Scope|Closure|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|Closure|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

at line 22
static void bootHasGlobalScopes()

Boot the has global scopes trait for a model.

Return Value

void

at line 30
static array resolveGlobalScopeAttributes()

Resolve the global scope class names from the attributes.

Return Value

array

at line 67
static mixed addGlobalScope(Scope|Closure|string $scope, Scope|Closure|null $implementation = null)

Register a new global scope on the model.

Boot-only. The scope persists in a static property for the worker lifetime and applies to every query for this model class across all coroutines.

Parameters

Scope|Closure|string $scope
Scope|Closure|null $implementation

Return Value

mixed

Exceptions

InvalidArgumentException

at line 91
static void addGlobalScopes(array $scopes)

Register multiple global scopes on the model.

Boot-only. Delegates to addGlobalScope() per entry; each scope persists in a static property for the worker lifetime.

Parameters

array $scopes

Return Value

void

at line 105
static bool hasGlobalScope(Scope|string $scope)

Determine if a model has a global scope.

Parameters

Scope|string $scope

Return Value

bool

at line 115
static Scope|Closure|null getGlobalScope(Scope|string $scope)

Get a global scope registered with the model.

Parameters

Scope|string $scope

Return Value

Scope|Closure|null

at line 130
static array getAllGlobalScopes()

Get all of the global scopes that are currently registered.

Return Value

array

at line 142
static void setAllGlobalScopes(array $scopes)

Set the current global scopes.

Boot or tests only. Replaces the worker-wide global scopes registry shared by every coroutine; per-request use changes scope behavior for every concurrent model query.

Parameters

array $scopes

Return Value

void

at line 150
array getGlobalScopes()

Get the global scopes for this class instance.

Return Value

array