trait HasAssignedModels

Traits

Build Permission relations from one immutable partition and team snapshot.

Methods

permissionBelongsToMany(string $related, string $table, string $foreignPivotKey, string $relatedPivotKey, string $relationName, PermissionRelationContext|null $context = null)

Build a partition-aware belongs-to-many relation.

permissionMorphToMany(string $related, string $table, string $foreignPivotKey, string $relatedPivotKey, string $relationName, bool $inverse = false, bool $teamScoped = false, PermissionRelationContext|null $context = null)

Build a partition-aware morph-to-many relation.

permissionRelationQuery(Model $related, PermissionPartition|null $partition)

Build the related query using the relation's captured partition.

void
ensurePermissionRelationParentMatches(PermissionRegistrar $registrar, PermissionPartition|null $partition)

Ensure a partition-bearing relation parent belongs to the captured partition.

applyPermissionPartitionToRelation(BelongsToMany $relation, PermissionPartition|null $partition)

Apply the captured partition to pivot reads and writes.

assignToModels(array|Collection|Model|int|string $models, string|null $modelClass = null)

Assign this role to the given models without removing existing assignments.

removeFromModels(array|Collection|Model|int|string $models, string|null $modelClass = null)

Remove this role from the given models.

syncModels(array|Collection|Model|int|string $models, string|null $modelClass = null)

Remove all current model associations and set the given ones.

relationForModel(string $modelClass, PermissionRelationContext|null $context = null)

Build a morphedByMany relation pointing to a specific model class.

Details

protected BelongsToMany permissionBelongsToMany(string $related, string $table, string $foreignPivotKey, string $relatedPivotKey, string $relationName, PermissionRelationContext|null $context = null)

Build a partition-aware belongs-to-many relation.

Parameters

string $related
string $table
string $foreignPivotKey
string $relatedPivotKey
string $relationName
PermissionRelationContext|null $context

Return Value

BelongsToMany

protected MorphToMany permissionMorphToMany(string $related, string $table, string $foreignPivotKey, string $relatedPivotKey, string $relationName, bool $inverse = false, bool $teamScoped = false, PermissionRelationContext|null $context = null)

Build a partition-aware morph-to-many relation.

Parameters

string $related
string $table
string $foreignPivotKey
string $relatedPivotKey
string $relationName
bool $inverse
bool $teamScoped
PermissionRelationContext|null $context

Return Value

MorphToMany

protected Builder permissionRelationQuery(Model $related, PermissionPartition|null $partition)

Build the related query using the relation's captured partition.

Parameters

Model $related
PermissionPartition|null $partition

Return Value

Builder

protected void ensurePermissionRelationParentMatches(PermissionRegistrar $registrar, PermissionPartition|null $partition)

Ensure a partition-bearing relation parent belongs to the captured partition.

Parameters

PermissionRegistrar $registrar
PermissionPartition|null $partition

Return Value

void

protected BelongsToMany applyPermissionPartitionToRelation(BelongsToMany $relation, PermissionPartition|null $partition)

Apply the captured partition to pivot reads and writes.

Parameters

BelongsToMany $relation
PermissionPartition|null $partition

Return Value

BelongsToMany

at line 28
HasAssignedModels assignToModels(array|Collection|Model|int|string $models, string|null $modelClass = null)

Assign this role to the given models without removing existing assignments.

Parameters

array|Collection|Model|int|string $models
string|null $modelClass

Return Value

HasAssignedModels

at line 76
HasAssignedModels removeFromModels(array|Collection|Model|int|string $models, string|null $modelClass = null)

Remove this role from the given models.

Parameters

array|Collection|Model|int|string $models
string|null $modelClass

Return Value

HasAssignedModels

at line 115
HasAssignedModels syncModels(array|Collection|Model|int|string $models, string|null $modelClass = null)

Remove all current model associations and set the given ones.

Parameters

array|Collection|Model|int|string $models
string|null $modelClass

Return Value

HasAssignedModels

at line 142
protected MorphToMany relationForModel(string $modelClass, PermissionRelationContext|null $context = null)

Build a morphedByMany relation pointing to a specific model class.

Parameters

string $modelClass
PermissionRelationContext|null $context

Return Value

MorphToMany