trait ScopesTrait

Methods

_scopeAll(Query $Query)

Global named scope scopeAll to use on models to return an unscoped unloaded collection

_scopeDefault(Query $Query)

Load default scopes

_scope_by(string $fn, array $parameters)

Called for scopeby Magic Function Creates a new ModelCollection and applies the passed scope

_scope_custom(string $scopeName, Query|null $Query = null)

Called for scope_ Magic Function Creates a new ModelCollection and applies the passed custom scope function

add_scope_condition(Condition|ConditionGroup|Query|string $new_condition)

Adds a condition to scope the following find functions

getScopeQuery(bool $applyDefaultScopes = true)

Returns the Query object which is being used for building the query The function creates a new Query object if required to enable lazy loading

void
registerDefaultScope($scopeName)

Registers the passed scope as default scope A default scope is present when the model is being loaded and can be removed using the unscope() function if required The passed scope must be defined in a scope[SCOPE_NAME] function e.g. scopeGroupId

void
resetScopeQuery()

Reset Scope to null

scope(string $scopeName, Query|null $scopeQuery = null)

No description

scopeAll()

No description

scope_by_id(int|array $id)

No description

void
setModelCollectionReference(ModelCollection $modelCollectionReference)

No description

unscope(string $scopeName = null, Query|null $scopeQuery = null)

Returns an unscoped Collection

Details

at line 100
Query _scopeAll(Query $Query)

Global named scope scopeAll to use on models to return an unscoped unloaded collection

Parameters

Query $Query Query

Return Value

Query

at line 111
Query _scopeDefault(Query $Query)

Load default scopes

Parameters

Query $Query

Return Value

Query

at line 143
protected ModelCollection _scope_by(string $fn, array $parameters)

Called for scopeby Magic Function Creates a new ModelCollection and applies the passed scope

Parameters

string $fn
array $parameters

Return Value

ModelCollection

at line 159
protected ModelCollection _scope_custom(string $scopeName, Query|null $Query = null)

Called for scope_ Magic Function Creates a new ModelCollection and applies the passed custom scope function

Parameters

string $scopeName

Name of the custom scope - e.g. Active - calls _scopeActive() on the model

Query|null $Query

Return Value

ModelCollection

at line 34
ModelCollection add_scope_condition(Condition|ConditionGroup|Query|string $new_condition)

Adds a condition to scope the following find functions

Parameters

Condition|ConditionGroup|Query|string $new_condition

Return Value

ModelCollection

at line 217
Query getScopeQuery(bool $applyDefaultScopes = true)

Returns the Query object which is being used for building the query The function creates a new Query object if required to enable lazy loading

Parameters

bool $applyDefaultScopes

Return Value

Query

at line 127
protected void registerDefaultScope($scopeName)

Registers the passed scope as default scope A default scope is present when the model is being loaded and can be removed using the unscope() function if required The passed scope must be defined in a scope[SCOPE_NAME] function e.g. scopeGroupId

Parameters

$scopeName

Return Value

void

at line 231
void resetScopeQuery()

Reset Scope to null

Return Value

void

at line 81
ModelCollection scope(string $scopeName, Query|null $scopeQuery = null)

No description

Parameters

string $scopeName
Query|null $scopeQuery

Return Value

ModelCollection

at line 16
ModelCollection scopeAll()

No description

Return Value

ModelCollection

at line 16
ModelCollection scope_by_id(int|array $id)

No description

Parameters

int|array $id

Return Value

ModelCollection

at line 88
void setModelCollectionReference(ModelCollection $modelCollectionReference)

No description

Parameters

ModelCollection $modelCollectionReference

Return Value

void

at line 56
ModelCollection unscope(string $scopeName = null, Query|null $scopeQuery = null)

Returns an unscoped Collection

Parameters

string $scopeName
Query|null $scopeQuery

Provide a specific Query Object you want to unscope

Return Value

ModelCollection