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>
64 lines
2.4 KiB
PHP
64 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Themes\Sections;
|
|
|
|
use App\Pricing\OfferShowcase;
|
|
use App\Themes\Theme;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
|
|
/**
|
|
* Large photo with headline and the availability search. Seasonal appearances replace photo and texts.
|
|
*/
|
|
class HeroSection extends Section
|
|
{
|
|
public static function key(): string
|
|
{
|
|
return 'hero';
|
|
}
|
|
|
|
public static function label(): string
|
|
{
|
|
return 'Titelbereich mit Suche';
|
|
}
|
|
|
|
public static function icon(): string
|
|
{
|
|
return 'heroicon-o-photo';
|
|
}
|
|
|
|
public static function schema(): array
|
|
{
|
|
return [
|
|
TextInput::make('eyebrow')->label('Kleine Überschrift')->maxLength(100),
|
|
TextInput::make('title')->label('Überschrift')->helperText('*Wort* wird hervorgehoben (kursiv).')->required()->maxLength(160),
|
|
Textarea::make('text')->label('Text')->rows(2)->maxLength(400),
|
|
static::photoSelect('photo_ids', 'Fotos', multiple: true)
|
|
->helperText('Gezeigt wird das erste Foto, das zum Erscheinungsbild passt; leer = automatisch ein Foto der Wohnung. '.self::SEASON_HINT),
|
|
Toggle::make('show_search')->label('Verfügbarkeitssuche anzeigen')->default(true),
|
|
Toggle::make('show_offer')
|
|
->label('Hervorgehobenes Sonderangebot im Titelbereich zeigen')
|
|
->helperText('Das wichtigste als „hervorgehoben“ markierte Angebot, sofern gerade eins gilt.')
|
|
->default(true),
|
|
];
|
|
}
|
|
|
|
public function data(Theme $theme, array $data): array
|
|
{
|
|
$featuredOffer = ($data['show_offer'] ?? true) && $theme->property()
|
|
? app(OfferShowcase::class)->current($theme->property(), limit: 1, featuredOnly: true)->first()
|
|
: null;
|
|
|
|
return [
|
|
'eyebrow' => $theme->text('hero.eyebrow', $data['eyebrow'] ?? null),
|
|
'title' => $theme->text('hero.title', $data['title'] ?? $theme->site->name),
|
|
'text' => $theme->text('hero.text', $data['text'] ?? null),
|
|
'photo' => $this->chosenPhotos($theme, $data['photo_ids'] ?? [])->first() ?? $this->automaticPhotos($theme, limit: 1)->first(),
|
|
'featuredOffer' => $featuredOffer,
|
|
'showSearch' => (bool) ($data['show_search'] ?? true),
|
|
'property' => $theme->property(),
|
|
];
|
|
}
|
|
}
|