October\Rain\Database\Relations\AttachOneOrMany


Protected Properties

protected string $relationName

relationName is the "name" of the relationship

protected bool $public

public is a default value for file public or protected state


Public Methods

public add()

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

add a model to this relationship type

public addCommonEagerConstraints()

public addCommonEagerConstraints(array $models): void 

addCommonEagerConstraints adds constraints without the field constraint, used to eager load multiple relations of a common type.

See Also

public addConstraints()

public addConstraints(): void 

addConstraints sets the field (relation name) constraint on the query

public addEagerConstraints()

public addEagerConstraints(array $models): void 

addEagerConstraints sets the field constraint for an eager load of the relation

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

public createFromFile()

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

public getForeignKey()

public getForeignKey(): void

public getOtherKey()

public getOtherKey(): void

public getRelationExistenceQuery()

public getRelationExistenceQuery(
    Illuminate\Database\Eloquent\Builder $query,
    Illuminate\Database\Eloquent\Builder $parentQuery,
    array|mixed $columns = [ 0 => '*']
): Illuminate\Database\Eloquent\Builder 

getRelationExistenceQuery adds the constraints for a relationship count query

public getRelationExistenceQueryForSelfRelation()

public getRelationExistenceQueryForSelfRelation(
    Illuminate\Database\Eloquent\Builder $query,
    Illuminate\Database\Eloquent\Builder $parentQuery,
    array|mixed $columns = [ 0 => '*']
): Illuminate\Database\Eloquent\Builder 

getRelationExistenceQueryForSelfRelation adds the constraints for a relationship query on the same table

public isPublic()

public isPublic(): void

isPublic determines if the file should be flagged "public" or not

public makeValidationFile()

public makeValidationFile($value): void

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

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

protected ensureAttachOneIsSingular($sessionKey = null): void

ensureAttachOneIsSingular ensures AttachOne only has one attachment, by deleting siblings for singular relations.

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