Banner zentral: je Website, Saison und Prioritaet, auch fuer Sonderangebote

Hinweise werden zu Bannern mit Website, Erscheinungsbildern, Prioritaet und
optionalem Sonderangebot (Text, Termin und Link aus dem Angebot, sichtbar nur
solange es beworben wird). Sonderangebote lassen sich mit einem Klick als Banner
zeigen; die Liste nennt das heute sichtbare Banner. Banner-Texte der
Erscheinungsbilder werden zu saisonalen Bannern.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-10-29 19:01:48 +01:00
1 parent 791786ed3e
commit d2b1a853dc
21 files changed
+618 -106

No files matched your search

@@ -0,0 +1,48 @@
<?php
namespace App\Models\Concerns;
use App\Models\Appearance;
/**
* For models with an "appearance_ids" list (photos, banners): none = all year, otherwise only while one of
* these appearances (summer, winter, Christmas …) is in effect.
*/
trait BelongsToAppearances
{
/**
* Appearance ids as integers (the form may deliver strings).
*
* @return list<int>
*/
public function appearanceIds(): array
{
return array_values(array_unique(array_map('intval', array_filter((array) $this->appearance_ids))));
}
/**
* Whether the record may be shown while this appearance is in effect: all-year ones always, seasonal ones in their seasons.
*/
public function fitsSeason(?Appearance $appearance): bool
{
return $this->appearanceIds() === [] || $this->isMadeFor($appearance);
}
/**
* Whether the record was chosen for this appearance.
*/
public function isMadeFor(?Appearance $appearance): bool
{
return $appearance !== null && in_array($appearance->id, $this->appearanceIds(), true);
}
/**
* Names of the appearances the record is made for (empty = all year).
*
* @return list<string>
*/
public function appearanceNames(): array
{
return array_values(array_intersect_key(Appearance::names(), array_flip($this->appearanceIds())));
}
}