'boolean']; } public const SLOTS = ['header', 'footer', 'cover']; /** * Das Bild eines Bildfelds als Ziel des Pickers: `element:`, `medium:` oder null. */ public function target(string $slot): ?string { $version = $this->getAttribute($slot.'_version_id'); $element = $this->getAttribute($slot.'_element_id'); return $version !== null ? 'element:'.$version : ($element !== null ? 'medium:'.$element : null); } /** * Die Spaltenwerte eines Bildfelds für ein Ziel des Pickers. * * @return array */ public static function columns(string $slot, ?string $target): array { $ref = TemplateImage::parse($target); return [ $slot.'_version_id' => ($ref['type'] ?? null) === 'version' ? $ref['id'] : null, $slot.'_element_id' => ($ref['type'] ?? null) === 'medium' ? $ref['id'] : null, ]; } public function headerVersion(): BelongsTo { return $this->belongsTo(ContentElementVersion::class, 'header_version_id'); } public function footerVersion(): BelongsTo { return $this->belongsTo(ContentElementVersion::class, 'footer_version_id'); } public function coverVersion(): BelongsTo { return $this->belongsTo(ContentElementVersion::class, 'cover_version_id'); } public function compositions(): HasMany { return $this->hasMany(Composition::class); } }