- Webseite > Videos (Datei, Standbild, Kapitel mit Raum im Grundriss); Upload bis 100 MB - Titelbereich: Video statt Foto (stumme Schleife, respektiert Bewegung reduzieren/Save-Data) und naechste freie Termine mit Gesamtpreis (NextFreeStays) - Neuer Baustein Rundgang (Video) mit waehlbarer Anordnung; Grundriss springt ins Video - Buchungsseite: Preis unter dem Kalender, Formular rechts, Ablauf als Grafik - Seebad: Fahrkarten, Fahrplan-Kapitel, Sonnenaufgang als einmaliges Ereignis Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
3.8 KiB
PHP
87 lines
3.8 KiB
PHP
<?php
|
||
|
||
namespace App\Themes\Sections;
|
||
|
||
use App\Availability\NextFreeStays;
|
||
use App\Pricing\OfferShowcase;
|
||
use App\Themes\Theme;
|
||
use Filament\Forms\Components\Select;
|
||
use Filament\Forms\Components\Textarea;
|
||
use Filament\Forms\Components\TextInput;
|
||
use Filament\Forms\Components\Toggle;
|
||
use Filament\Schemas\Components\Utilities\Get;
|
||
|
||
/**
|
||
* Large photo (or a silent video loop) with headline, the availability search and the next free dates.
|
||
* 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),
|
||
static::videoSelect('video_id', 'Video statt Foto')
|
||
->helperText('Läuft stumm in Schleife an der Stelle des Fotos (Webseite › Videos). Bei „Bewegung reduzieren“ und langsamer Verbindung bleibt das Standbild des Videos stehen.'),
|
||
Toggle::make('show_search')->label('Verfügbarkeitssuche anzeigen')->default(true),
|
||
Toggle::make('show_free_dates')
|
||
->label('Nächste freie Termine zeigen')
|
||
->helperText('Bis zu drei buchbare Zeiträume mit Gesamtpreis; ein Klick öffnet die Anfrage mit diesen Daten.')
|
||
->default(true)
|
||
->live(),
|
||
Select::make('free_dates_nights')
|
||
->label('Mindestens … Nächte')
|
||
->options(array_combine(range(2, 7), array_map(fn (int $nights): string => "{$nights} Nächte", range(2, 7))))
|
||
->default(3)
|
||
->selectablePlaceholder(false)
|
||
->visible(fn (Get $get): bool => (bool) $get('show_free_dates')),
|
||
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
|
||
{
|
||
$property = $theme->property();
|
||
$featuredOffer = ($data['show_offer'] ?? true) && $property
|
||
? app(OfferShowcase::class)->current($property, limit: 1, featuredOnly: true)->first()
|
||
: null;
|
||
$freeStays = ($data['show_free_dates'] ?? false) && $property
|
||
? app(NextFreeStays::class)->for($property, nights: (int) ($data['free_dates_nights'] ?? 3))
|
||
: [];
|
||
|
||
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(),
|
||
'video' => $this->video($data['video_id'] ?? null),
|
||
'freeStays' => $freeStays,
|
||
'featuredOffer' => $featuredOffer,
|
||
'showSearch' => (bool) ($data['show_search'] ?? true),
|
||
'property' => $property,
|
||
];
|
||
}
|
||
}
|