trait SupportsInverseRelations (View source)

Properties

protected string|null $inverseRelationship

The name of the inverse relationship.

Methods

$this
inverse(string|null $relation = null)

Instruct Eloquent to link the related models back to the parent after the relationship query has run.

$this
chaperone(string|null $relation = null)

Instruct Eloquent to link the related models back to the parent after the relationship query has run.

string|null
guessInverseRelation()

Guess the name of the inverse relationship.

array
getPossibleInverseRelations()

Get the possible inverse relations for the parent model.

applyInverseRelationToCollection(Collection $models, Model|null $parent = null)

Set the inverse relation on all models in a collection.

applyInverseRelationToModel(Model $model, Model|null $parent = null)

Set the inverse relation on a model.

string|null
getInverseRelationship()

Get the name of the inverse relationship.

$this
withoutInverse()

Remove the chaperone / inverse relationship for this query.

$this
withoutChaperone()

Remove the chaperone / inverse relationship for this query.

Details

$this inverse(string|null $relation = null)

Instruct Eloquent to link the related models back to the parent after the relationship query has run.

Alias of "chaperone".

Parameters

string|null $relation

Return Value

$this

$this chaperone(string|null $relation = null)

Instruct Eloquent to link the related models back to the parent after the relationship query has run.

Parameters

string|null $relation

Return Value

$this

protected string|null guessInverseRelation()

Guess the name of the inverse relationship.

Return Value

string|null

protected array getPossibleInverseRelations()

Get the possible inverse relations for the parent model.

Return Value

array

protected Collection applyInverseRelationToCollection(Collection $models, Model|null $parent = null)

Set the inverse relation on all models in a collection.

Parameters

Collection $models
Model|null $parent

Return Value

Collection

protected Model applyInverseRelationToModel(Model $model, Model|null $parent = null)

Set the inverse relation on a model.

Parameters

Model $model
Model|null $parent

Return Value

Model

string|null getInverseRelationship()

Get the name of the inverse relationship.

Return Value

string|null

$this withoutInverse()

Remove the chaperone / inverse relationship for this query.

Alias of "withoutChaperone".

Return Value

$this

$this withoutChaperone()

Remove the chaperone / inverse relationship for this query.

Return Value

$this