trait BuildsPermissionRelations

Build Permission relations from one immutable partition and team snapshot.

The captured context must constrain related and pivot queries for the relation's lifetime, even if ambient context later changes.

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.

Details

at line 35
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

at line 72
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

at line 129
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

at line 144
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

at line 178
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