trait SupportsPivotInverseRelations

Properties

protected string|null $declaringInverseRelationship

The name of the declaring model's relationship on the pivot.

protected string|null $relatedInverseRelationship

The name of the related model's relationship on the pivot.

Methods

chaperone(string|null $declaring = null, string|null $related = null)

Instruct Eloquent to link the declaring and related models back to the pivot after the relationship query has run.

withoutChaperone()

Remove the chaperone relationships for this query.

string|null
resolvePivotInverseRelation(Model $pivotModel, string|null $relation, string $foreignKey, Model $model)

Resolve the inverse relation name on the pivot for a given model.

string|null
guessPivotInverseRelation(Model $pivotModel, string $foreignKey, Model $model)

Attempt to guess the inverse relation name on the pivot for a given model.

string
relationNameFromPivotKey(string $pivotKey, Model $model)

Derive the inverse relationship name from a pivot key.

void
applyChaperonesToPivot(Model $pivot, Model $declaring, Model $related)

Apply chaperone relationships to a pivot model instance.

Details

at line 29
SupportsPivotInverseRelations chaperone(string|null $declaring = null, string|null $related = null)

Instruct Eloquent to link the declaring and related models back to the pivot after the relationship query has run.

Parameters

string|null $declaring
string|null $related

Return Value

SupportsPivotInverseRelations

at line 74
SupportsPivotInverseRelations withoutChaperone()

Remove the chaperone relationships for this query.

at line 90
protected string|null resolvePivotInverseRelation(Model $pivotModel, string|null $relation, string $foreignKey, Model $model)

Resolve the inverse relation name on the pivot for a given model.

If an explicit name is provided and invalid, an exception is thrown. If guessing fails, null is returned.

Parameters

Model $pivotModel
string|null $relation
string $foreignKey
Model $model

Return Value

string|null

Exceptions

RelationNotFoundException

at line 106
protected string|null guessPivotInverseRelation(Model $pivotModel, string $foreignKey, Model $model)

Attempt to guess the inverse relation name on the pivot for a given model.

Parameters

Model $pivotModel
string $foreignKey
Model $model

Return Value

string|null

at line 122
protected string relationNameFromPivotKey(string $pivotKey, Model $model)

Derive the inverse relationship name from a pivot key.

Parameters

string $pivotKey
Model $model

Return Value

string

at line 130
protected void applyChaperonesToPivot(Model $pivot, Model $declaring, Model $related)

Apply chaperone relationships to a pivot model instance.

Parameters

Model $pivot
Model $declaring
Model $related

Return Value

void