October\Rain\Database\Relations\TranslatableAttachOneOrMany
Overview
TranslatableAttachOneOrMany stores attachments per locale and reads the default locale files when a locale has none.
Protected Properties
protected string|null $attachmentLocale
attachmentLocale suffixes the field column, null for the default locale.
protected bool $useFallback
useFallback reads the default locale files when the locale has none of its own.
Public Methods
public __construct()
public __construct(
$query,
$parent,
$type,
$id,
$isPublic,
$localKey,
$relationName = null
): void
__construct resolves the locale from the parent model before the constraints are added.
public addEagerConstraints()
public addEagerConstraints($models): void
addEagerConstraints resolves the fallback per parent model for an eager load.
public getAttachmentField()
public getAttachmentField(): string
getAttachmentField returns the relation name with a locale suffix for non-default locales.
public getAttachmentLocale()
public getAttachmentLocale(): string|null
getAttachmentLocale returns the locale this relation stores files under, or null for the default locale.
public getRelationExistenceQuery()
public getRelationExistenceQuery(
$query,
$parentQuery,
$columns = [ 0 => '*']
): void
getRelationExistenceQuery resolves the fallback for has and count queries.
public getResults()
public getResults(): void
getResults reads the locale files, or the default locale files when the locale has none.
public newAttachmentQuery()
public newAttachmentQuery(): void
newAttachmentQuery returns a query for the parent's files of this relation in every locale.
public remove()
public remove($model, $sessionKey = null): void
remove clears the loaded relation so the next read can fall back to the default locale files.
public setSimpleValue()
public setSimpleValue($value): void
setSimpleValue clears the loaded relation when emptied so reads fall back to the default locale files.
public usesFallback()
public usesFallback(): bool
usesFallback returns true when reads resolve to the default locale files for a locale without its own.
public withoutFallback()
public withoutFallback(): void
withoutFallback reads only the files stored under the active locale.
Protected Methods
protected addResolvedFieldConstraint()
protected addResolvedFieldConstraint($query): void
addResolvedFieldConstraint matches the locale field, or the default field when the parent has no locale files.
protected resolveAttachmentLocale()
protected resolveAttachmentLocale($parent): string|null
resolveAttachmentLocale returns the active locale when it differs from the default locale.