October\Rain\Database\Relations\HasOneOrMany


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 addMany()

public addMany(array $models, $sessionKey = null): void 

addMany attaches an array of models to the parent instance with deferred binding support

public create()

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

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

public getForeignKey()

public getForeignKey(): void

public getOtherKey()

public getOtherKey(): void

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 saveMany()

public saveMany(array $models, $sessionKey = null): array 

saveMany is an alias for the addMany() method

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