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

+2 -37
View File
@@ -3,6 +3,7 @@
namespace App\Models;
use App\Enums\PhotoCategory;
use App\Models\Concerns\BelongsToAppearances;
use App\Models\Concerns\BelongsToTenant;
use Database\Factories\PhotoFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
@@ -26,7 +27,7 @@
class Photo extends Model implements HasMedia
{
/** @use HasFactory<PhotoFactory> */
use BelongsToTenant, HasFactory, InteractsWithMedia;
use BelongsToAppearances, BelongsToTenant, HasFactory, InteractsWithMedia;
public const COLLECTION = 'image';
@@ -127,42 +128,6 @@ public static function automatic(?Property $property, ?Appearance $appearance, ?
->values();
}
/**
* 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 photo may be shown while this appearance is in effect: all-year photos always, seasonal ones in their seasons.
*/
public function fitsSeason(?Appearance $appearance): bool
{
return $this->appearanceIds() === [] || $this->isMadeFor($appearance);
}
/**
* Whether the photo was chosen for this appearance (seasonal photos come first while it is in effect).
*/
public function isMadeFor(?Appearance $appearance): bool
{
return $appearance !== null && in_array($appearance->id, $this->appearanceIds(), true);
}
/**
* Names of the appearances the photo 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())));
}
public function url(string $size = 'md'): string
{
return $this->getFirstMediaUrl(self::COLLECTION, $size);