*/ use HasFactory; /** * Texts an appearance can replace, with their admin labels. Sections read them through Theme::text(). */ public const OVERRIDABLE = [ 'banner.text' => 'Banner: Text', 'banner.link_label' => 'Banner: Link-Text', 'banner.link_url' => 'Banner: Link-Ziel', 'hero.eyebrow' => 'Titelbereich: kleine Überschrift', 'hero.title' => 'Titelbereich: Überschrift', 'hero.text' => 'Titelbereich: Text', 'cta.title' => 'Abschluss: Überschrift', 'cta.text' => 'Abschluss: Text', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'is_default' => 'boolean', 'is_active' => 'boolean', 'tokens' => 'array', 'overrides' => 'array', ]; } /** * @return BelongsTo */ public function site(): BelongsTo { return $this->belongsTo(Site::class); } /** * @return BelongsTo */ public function heroPhoto(): BelongsTo { return $this->belongsTo(Photo::class, 'hero_photo_id'); } /** * @return BelongsTo */ public function featuredOffer(): BelongsTo { return $this->belongsTo(SpecialOffer::class, 'featured_offer_id'); } public function covers(CarbonInterface $date): bool { if ($this->starts_md === null || $this->ends_md === null) { return false; } $day = $date->format('m-d'); return $this->starts_md <= $this->ends_md ? $day >= $this->starts_md && $day <= $this->ends_md : $day >= $this->starts_md || $day <= $this->ends_md; } public function override(string $key): ?string { $value = data_get($this->overrides, $key); return filled($value) ? (string) $value : null; } }