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 createMany()
public createMany($records, $sessionKey = null): void
createMany creates multiple instances of related models.
public createManyQuietly()
public createManyQuietly($records, $sessionKey = null): void
createManyQuietly creates multiple instances without raising any events.
public createQuietly()
public createQuietly($attributes = [], $sessionKey = null): void
createQuietly creates a new instance without raising any events.
public getAttachmentField()
public getAttachmentField(): string
getAttachmentField returns the value stored in the field column for this relation.
public getForeignKey()
public getForeignKey(): void
public getOtherKey()
public getOtherKey(): void
public getRelatedKeyName()
public getRelatedKeyName(): string
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 saveMany()
public saveMany($models, $sessionKey = null): void
saveMany saves multiple models with deferred binding support.
public saveManyQuietly()
public saveManyQuietly($models, $sessionKey = null): void
saveManyQuietly saves multiple models without raising any events.
public saveQuietly()
public saveQuietly($model, $sessionKey = null): void
saveQuietly saves the supplied related model without raising any events.
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 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