Protected Properties

protected string $relationName

relationName is the "name" of the relationship.

Public Methods

public add()

public add($model, $sessionKey = null): void

add a model to this relationship type.

public create()

public create($attributes = [], $sessionKey = null): void

create a new instance of this related model with deferred binding support.

public getRelatedKeyName()

public getRelatedKeyName(): string 

public remove()

public remove($model, $sessionKey = null): void

remove a model from this relationship type.

public save()

public save($model, $sessionKey = null): void

save the supplied related model with deferred binding support.

public withDeferred()

public withDeferred(
    string|null $sessionKey = null
): Illuminate\Database\Query\Builder 

withDeferred returns a new model query with deferred bindings added, this will reset any constraints that come before it

public withDeferredQuery()

public withDeferredQuery(
    Illuminate\Database\Query\Builder|null $newQuery = null,
    string|null $sessionKey = null
): Illuminate\Database\Query\Builder 

withDeferredQuery returns the supplied model query, or current model query, with deferred bindings added, this will preserve any constraints that came before it

Protected Methods

protected ensureRelationIsEmpty()

protected ensureRelationIsEmpty(): void

ensureRelationIsEmpty ensures the relation is empty, either deleted or nulled.

protected getWithDeferredQualifiedKeyName()

protected getWithDeferredQualifiedKeyName(

): Illuminate\Database\Query\Expression 

getWithDeferredQualifiedKeyName returns the related "slave id" key in a database friendly format.

protected isModelRemovable()

protected isModelRemovable($model): bool 

isModelRemovable returns true if an existing model is already associated