Saisonfotos am Foto statt am Erscheinungsbild

Ein Foto gehoert zu keinem (ganzjaehrig) oder mehreren Erscheinungsbildern und
erscheint nur dort, vor den ganzjaehrigen Fotos. Bausteine waehlen "automatisch"
oder eine eigene Auswahl; Titelbereich und Abschluss zeigen das erste passende
Foto ihrer Liste. Titelbild und "Bilder je Baustein" des Erscheinungsbilds werden
in die Bausteine uebernommen und entfallen dort.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-10-29 18:53:56 +01:00
1 parent d02f3e05c7
commit 791786ed3e
21 files changed
+449 -235

No files matched your search

+4 -11
View File
@@ -3,10 +3,10 @@
namespace App\Themes\Sections;
use App\Enums\PhotoCategory;
use App\Models\Photo;
use App\Themes\Theme;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Utilities\Get;
/**
* Photo gallery of one category (or all), opened in a lightbox.
@@ -32,26 +32,19 @@ public static function schema(): array
{
return [
TextInput::make('heading')->label('Überschrift')->maxLength(120),
Select::make('category')->label('Bilder')->options(['all' => 'Alle', ...collect(PhotoCategory::forGalleries())->mapWithKeys(fn (PhotoCategory $category): array => [$category->value => $category->getLabel()])->all()])->default('all'),
...static::photoSourceFields('Automatisch nach Kategorie'),
Select::make('category')->label('Kategorie')->visible(fn (Get $get): bool => $get('photo_source') !== 'selection')->options(['all' => 'Alle', ...collect(PhotoCategory::forGalleries())->mapWithKeys(fn (PhotoCategory $category): array => [$category->value => $category->getLabel()])->all()])->default('all'),
TextInput::make('limit')->label('Anzahl (leer = alle)')->integer()->minValue(1),
];
}
public static function photoSlots(): array
{
return ['photo_ids' => ['label' => 'Galerie', 'type' => self::SLOT_COLLECTION]];
}
public function data(Theme $theme, array $data): array
{
$category = PhotoCategory::tryFrom($data['category'] ?? '');
return [
'heading' => $data['heading'] ?? null,
'photos' => $this->withSeasonalPhotos($theme, $data, 'photo_ids', Photo::query()->published()->forGalleries()->forProperty($theme->property())->with('media')
->when($category, fn ($query) => $query->where('category', $category))
->when(filled($data['limit'] ?? null), fn ($query) => $query->limit((int) $data['limit']))
->get()),
'photos' => $this->sourcedPhotos($theme, $data, $category, filled($data['limit'] ?? null) ? (int) $data['limit'] : null),
];
}
}