From 66e82d61f55eecdcf49bd9e5d5383172090cfb79 Mon Sep 17 00:00:00 2001 From: Lars Stommer Date: Thu, 22 Oct 2026 15:04:21 +0200 Subject: [PATCH] Theme-System mit Basis-Theme Ostsee-Licht, Bausteinen und saisonalen Erscheinungsbildern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Sites (Domain, Theme, Farben; mehrfähig für weitere Vermieter), Seiten aus Bausteinen mit Menüs, Erscheinungsbilder mit jährlichem Zeitplan, Priorität und signierter Vorschau - Theme-Kern (app/Themes): Manifest, Registry, Vererbung (Child-Themes), Token-Farben als CSS-Variablen, Bausteinkatalog als Registry (config/themes.php) - 15 Bausteine: Titelbereich mit Suche, Eckdaten, Text mit Bildern, Galerie, Ausstattung, Lage, Preise, Angebote, Kalender & Anfrage, Bewertungen, Gastgeber, FAQ, Abschluss, Kontakt, Fließtext - Theme Ostsee-Licht: Layout, Kopf/Fuß, Banner, mobile Buchungsleiste, Lightbox, selbst gehostete Schriften, Reduced Motion - Seiten Start, Wohnung, Kühlungsborn, Preise & Buchung, Kontakt, Impressum, Datenschutz; Sitemap, robots.txt, JSON-LD - Admin: Seiten-Baukasten, Erscheinungsbilder, Websites - Dokumentation docs/THEMES.md inkl. Übergabe für die Design-Sitzung Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 1 + CLAUDE.md | 1 + app/Filament/Pages/EditContent.php | 2 +- .../Resources/Amenities/AmenityResource.php | 2 +- .../Appearances/AppearanceResource.php | 57 +++++ .../Appearances/Pages/CreateAppearance.php | 11 + .../Appearances/Pages/EditAppearance.php | 19 ++ .../Appearances/Pages/ListAppearances.php | 19 ++ .../Appearances/Schemas/AppearanceForm.php | 110 +++++++++ .../Appearances/Tables/AppearancesTable.php | 50 ++++ app/Filament/Resources/Faqs/FaqResource.php | 2 +- .../Resources/Notices/NoticeResource.php | 2 +- app/Filament/Resources/Pages/PageResource.php | 57 +++++ .../Resources/Pages/Pages/CreatePage.php | 11 + .../Resources/Pages/Pages/EditPage.php | 19 ++ .../Resources/Pages/Pages/ListPages.php | 19 ++ .../Resources/Pages/Schemas/PageForm.php | 67 ++++++ .../Resources/Pages/Tables/PagesTable.php | 39 +++ .../Resources/Photos/PhotoResource.php | 2 +- .../Properties/Schemas/PropertyForm.php | 6 + .../Resources/Sites/Pages/CreateSite.php | 11 + .../Resources/Sites/Pages/EditSite.php | 19 ++ .../Resources/Sites/Pages/ListSites.php | 19 ++ .../Resources/Sites/Schemas/SiteForm.php | 42 ++++ app/Filament/Resources/Sites/SiteResource.php | 57 +++++ .../Resources/Sites/Tables/SitesTable.php | 27 +++ app/Http/Controllers/PageController.php | 97 ++++++++ app/Http/Middleware/ResolveTheme.php | 24 ++ app/Livewire/BookingRequest.php | 21 ++ app/Models/Appearance.php | 95 ++++++++ app/Models/Page.php | 62 +++++ app/Models/Property.php | 1 + app/Models/Site.php | 81 +++++++ app/Policies/AppearancePolicy.php | 13 + app/Policies/PagePolicy.php | 13 + app/Policies/SitePolicy.php | 11 + app/Providers/ThemeServiceProvider.php | 23 ++ app/Support/Content.php | 4 +- app/Themes/SectionRegistry.php | 71 ++++++ app/Themes/Sections/AmenitiesSection.php | 48 ++++ app/Themes/Sections/BookingSection.php | 45 ++++ app/Themes/Sections/CallToActionSection.php | 51 ++++ app/Themes/Sections/ContactSection.php | 46 ++++ app/Themes/Sections/FactsSection.php | 46 ++++ app/Themes/Sections/FaqSection.php | 46 ++++ app/Themes/Sections/GallerySection.php | 52 ++++ app/Themes/Sections/HeroSection.php | 55 +++++ app/Themes/Sections/HostSection.php | 46 ++++ app/Themes/Sections/LocationSection.php | 57 +++++ app/Themes/Sections/OffersSection.php | 56 +++++ app/Themes/Sections/PricesSection.php | 52 ++++ app/Themes/Sections/ReviewsSection.php | 53 +++++ app/Themes/Sections/RichTextSection.php | 64 +++++ app/Themes/Sections/Section.php | 109 +++++++++ app/Themes/Sections/TextImageSection.php | 55 +++++ app/Themes/Theme.php | 142 +++++++++++ app/Themes/ThemeFactory.php | 56 +++++ app/Themes/ThemeManifest.php | 51 ++++ app/Themes/ThemeRegistry.php | 67 ++++++ bootstrap/app.php | 3 +- bootstrap/providers.php | 9 +- config/content.php | 33 +-- config/themes.php | 54 +++++ database/factories/AppearanceFactory.php | 29 +++ database/factories/PageFactory.php | 30 +++ database/factories/SiteFactory.php | 27 +++ .../2026_10_22_144431_create_sites_table.php | 33 +++ .../2026_10_22_144433_create_pages_table.php | 39 +++ ..._10_22_144435_create_appearances_table.php | 38 +++ ...144438_add_site_id_to_properties_table.php | 28 +++ database/seeders/DatabaseSeeder.php | 2 +- database/seeders/SiteSeeder.php | 184 +++++++++++++++ docs/KONZEPT.md | 4 +- docs/THEMES.md | 174 ++++++++++++++ package-lock.json | 22 ++ package.json | 2 + public/robots.txt | 2 - resources/css/app.css | 37 --- resources/js/app.js | 1 - resources/themes/ostsee-licht/theme.css | 146 ++++++++++++ resources/themes/ostsee-licht/theme.js | 45 ++++ resources/themes/ostsee-licht/theme.json | 25 ++ .../ostsee-licht/views/layouts/app.blade.php | 58 +++++ .../themes/ostsee-licht/views/page.blade.php | 18 ++ .../views/partials/banner.blade.php | 11 + .../views/partials/footer.blade.php | 19 ++ .../views/partials/header.blade.php | 29 +++ .../views/partials/image.blade.php | 14 ++ .../partials/mobile-booking-bar.blade.php | 6 + .../views/sections/amenities.blade.php | 17 ++ .../views/sections/booking.blade.php | 11 + .../views/sections/contact.blade.php | 22 ++ .../ostsee-licht/views/sections/cta.blade.php | 10 + .../views/sections/facts.blade.php | 17 ++ .../ostsee-licht/views/sections/faq.blade.php | 24 ++ .../views/sections/gallery.blade.php | 18 ++ .../views/sections/hero.blade.php | 32 +++ .../views/sections/host.blade.php | 13 + .../views/sections/location.blade.php | 24 ++ .../views/sections/offers.blade.php | 17 ++ .../views/sections/prices.blade.php | 35 +++ .../views/sections/reviews.blade.php | 31 +++ .../views/sections/rich_text.blade.php | 8 + .../views/sections/text_image.blade.php | 21 ++ resources/views/booking.blade.php | 11 - .../views/components/layouts/site.blade.php | 39 --- .../views/livewire/booking-request.blade.php | 92 ++++---- .../views/livewire/review-form.blade.php | 38 +-- resources/views/marketing-consent.blade.php | 20 +- resources/views/review.blade.php | 16 +- resources/views/sitemap.blade.php | 9 + resources/views/welcome.blade.php | 222 ----------------- routes/web.php | 17 +- tests/Feature/BookingRequestPageTest.php | 3 +- tests/Feature/ExampleTest.php | 19 -- tests/Feature/ThemeSystemTest.php | 223 ++++++++++++++++++ tests/Feature/WebsiteContentTest.php | 6 +- tests/Unit/ExampleTest.php | 16 -- vite.config.js | 10 +- 119 files changed, 4066 insertions(+), 481 deletions(-) create mode 100644 app/Filament/Resources/Appearances/AppearanceResource.php create mode 100644 app/Filament/Resources/Appearances/Pages/CreateAppearance.php create mode 100644 app/Filament/Resources/Appearances/Pages/EditAppearance.php create mode 100644 app/Filament/Resources/Appearances/Pages/ListAppearances.php create mode 100644 app/Filament/Resources/Appearances/Schemas/AppearanceForm.php create mode 100644 app/Filament/Resources/Appearances/Tables/AppearancesTable.php create mode 100644 app/Filament/Resources/Pages/PageResource.php create mode 100644 app/Filament/Resources/Pages/Pages/CreatePage.php create mode 100644 app/Filament/Resources/Pages/Pages/EditPage.php create mode 100644 app/Filament/Resources/Pages/Pages/ListPages.php create mode 100644 app/Filament/Resources/Pages/Schemas/PageForm.php create mode 100644 app/Filament/Resources/Pages/Tables/PagesTable.php create mode 100644 app/Filament/Resources/Sites/Pages/CreateSite.php create mode 100644 app/Filament/Resources/Sites/Pages/EditSite.php create mode 100644 app/Filament/Resources/Sites/Pages/ListSites.php create mode 100644 app/Filament/Resources/Sites/Schemas/SiteForm.php create mode 100644 app/Filament/Resources/Sites/SiteResource.php create mode 100644 app/Filament/Resources/Sites/Tables/SitesTable.php create mode 100644 app/Http/Controllers/PageController.php create mode 100644 app/Http/Middleware/ResolveTheme.php create mode 100644 app/Models/Appearance.php create mode 100644 app/Models/Page.php create mode 100644 app/Models/Site.php create mode 100644 app/Policies/AppearancePolicy.php create mode 100644 app/Policies/PagePolicy.php create mode 100644 app/Policies/SitePolicy.php create mode 100644 app/Providers/ThemeServiceProvider.php create mode 100644 app/Themes/SectionRegistry.php create mode 100644 app/Themes/Sections/AmenitiesSection.php create mode 100644 app/Themes/Sections/BookingSection.php create mode 100644 app/Themes/Sections/CallToActionSection.php create mode 100644 app/Themes/Sections/ContactSection.php create mode 100644 app/Themes/Sections/FactsSection.php create mode 100644 app/Themes/Sections/FaqSection.php create mode 100644 app/Themes/Sections/GallerySection.php create mode 100644 app/Themes/Sections/HeroSection.php create mode 100644 app/Themes/Sections/HostSection.php create mode 100644 app/Themes/Sections/LocationSection.php create mode 100644 app/Themes/Sections/OffersSection.php create mode 100644 app/Themes/Sections/PricesSection.php create mode 100644 app/Themes/Sections/ReviewsSection.php create mode 100644 app/Themes/Sections/RichTextSection.php create mode 100644 app/Themes/Sections/Section.php create mode 100644 app/Themes/Sections/TextImageSection.php create mode 100644 app/Themes/Theme.php create mode 100644 app/Themes/ThemeFactory.php create mode 100644 app/Themes/ThemeManifest.php create mode 100644 app/Themes/ThemeRegistry.php create mode 100644 config/themes.php create mode 100644 database/factories/AppearanceFactory.php create mode 100644 database/factories/PageFactory.php create mode 100644 database/factories/SiteFactory.php create mode 100644 database/migrations/2026_10_22_144431_create_sites_table.php create mode 100644 database/migrations/2026_10_22_144433_create_pages_table.php create mode 100644 database/migrations/2026_10_22_144435_create_appearances_table.php create mode 100644 database/migrations/2026_10_22_144438_add_site_id_to_properties_table.php create mode 100644 database/seeders/SiteSeeder.php create mode 100644 docs/THEMES.md delete mode 100644 public/robots.txt delete mode 100644 resources/css/app.css delete mode 100644 resources/js/app.js create mode 100644 resources/themes/ostsee-licht/theme.css create mode 100644 resources/themes/ostsee-licht/theme.js create mode 100644 resources/themes/ostsee-licht/theme.json create mode 100644 resources/themes/ostsee-licht/views/layouts/app.blade.php create mode 100644 resources/themes/ostsee-licht/views/page.blade.php create mode 100644 resources/themes/ostsee-licht/views/partials/banner.blade.php create mode 100644 resources/themes/ostsee-licht/views/partials/footer.blade.php create mode 100644 resources/themes/ostsee-licht/views/partials/header.blade.php create mode 100644 resources/themes/ostsee-licht/views/partials/image.blade.php create mode 100644 resources/themes/ostsee-licht/views/partials/mobile-booking-bar.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/amenities.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/booking.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/contact.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/cta.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/facts.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/faq.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/gallery.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/hero.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/host.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/location.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/offers.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/prices.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/reviews.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/rich_text.blade.php create mode 100644 resources/themes/ostsee-licht/views/sections/text_image.blade.php delete mode 100644 resources/views/booking.blade.php delete mode 100644 resources/views/components/layouts/site.blade.php create mode 100644 resources/views/sitemap.blade.php delete mode 100644 resources/views/welcome.blade.php delete mode 100644 tests/Feature/ExampleTest.php create mode 100644 tests/Feature/ThemeSystemTest.php delete mode 100644 tests/Unit/ExampleTest.php diff --git a/AGENTS.md b/AGENTS.md index dae5f87..e76b757 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,6 +12,7 @@ # Ferienwohnung Stommer - Business operations live in `app/Actions` (CreateReservation, ConfirmBooking, …); Filament pages and Livewire components call them instead of changing bookings directly. - Special offers are evaluated automatically by `PriceCalculator`; discounts are `QuoteLineType::Discount` lines with negative amounts. - Portal sync lives in `app/Channels` (connector interface + registry in `config/channels.php`, iCal connector/parser/feed). Our system leads; `SyncChannel` imports portal occupations as `BlockedPeriod` rows with `channel_id`; each channel's export feed excludes its own blocks. Observers on Booking/BlockedPeriod create `ChannelTask`s for portals with `requires_manual_blocking`. Portal booking e-mails are a fast path (`app/Channels/Mail`, `ProcessPortalMail`): they create blocks with source `email`, which `SyncChannel` later confirms/replaces and never removes as stale. Portal analysis: `docs/PORTALE.md`. +- Website = theme system (`docs/THEMES.md`): themes live in `resources/themes/` (theme.json, theme.css, theme.js, views); views resolve via the `theme::` namespace (theme → parent → base `ostsee-licht`). Pages are lists of sections (`app/Themes/Sections`, catalogue in `config/themes.php`); seasonal `Appearance`s override tokens/texts/hero photo. Theme views use only token colour classes (`bg-accent`, `text-muted`, …). Resolve `Theme` lazily (`app(Theme::class)`), never in constructors – middleware `ResolveTheme` replaces it per request. - Vite fonts plugin is removed on purpose (corporate proxy breaks remote font downloads, and fonts must be self-hosted for GDPR). - PHP/Composer on this machine: winget package dir `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.8.4_*` (Composer as `composer\composer.phar` there). - Git remote: Gitea `https://gitea.stommer.de/Lars/fewo-stommer.git`, branch `main`. diff --git a/CLAUDE.md b/CLAUDE.md index dae5f87..e76b757 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,6 +12,7 @@ # Ferienwohnung Stommer - Business operations live in `app/Actions` (CreateReservation, ConfirmBooking, …); Filament pages and Livewire components call them instead of changing bookings directly. - Special offers are evaluated automatically by `PriceCalculator`; discounts are `QuoteLineType::Discount` lines with negative amounts. - Portal sync lives in `app/Channels` (connector interface + registry in `config/channels.php`, iCal connector/parser/feed). Our system leads; `SyncChannel` imports portal occupations as `BlockedPeriod` rows with `channel_id`; each channel's export feed excludes its own blocks. Observers on Booking/BlockedPeriod create `ChannelTask`s for portals with `requires_manual_blocking`. Portal booking e-mails are a fast path (`app/Channels/Mail`, `ProcessPortalMail`): they create blocks with source `email`, which `SyncChannel` later confirms/replaces and never removes as stale. Portal analysis: `docs/PORTALE.md`. +- Website = theme system (`docs/THEMES.md`): themes live in `resources/themes/` (theme.json, theme.css, theme.js, views); views resolve via the `theme::` namespace (theme → parent → base `ostsee-licht`). Pages are lists of sections (`app/Themes/Sections`, catalogue in `config/themes.php`); seasonal `Appearance`s override tokens/texts/hero photo. Theme views use only token colour classes (`bg-accent`, `text-muted`, …). Resolve `Theme` lazily (`app(Theme::class)`), never in constructors – middleware `ResolveTheme` replaces it per request. - Vite fonts plugin is removed on purpose (corporate proxy breaks remote font downloads, and fonts must be self-hosted for GDPR). - PHP/Composer on this machine: winget package dir `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.8.4_*` (Composer as `composer\composer.phar` there). - Git remote: Gitea `https://gitea.stommer.de/Lars/fewo-stommer.git`, branch `main`. diff --git a/app/Filament/Pages/EditContent.php b/app/Filament/Pages/EditContent.php index a5edcc8..10cda0e 100644 --- a/app/Filament/Pages/EditContent.php +++ b/app/Filament/Pages/EditContent.php @@ -39,7 +39,7 @@ class EditContent extends Page protected static ?string $slug = 'texte'; - protected static ?int $navigationSort = 2; + protected static ?int $navigationSort = 3; /** @var array */ public array $data = []; diff --git a/app/Filament/Resources/Amenities/AmenityResource.php b/app/Filament/Resources/Amenities/AmenityResource.php index 09d8d45..1bfe7c8 100644 --- a/app/Filament/Resources/Amenities/AmenityResource.php +++ b/app/Filament/Resources/Amenities/AmenityResource.php @@ -27,7 +27,7 @@ class AmenityResource extends Resource protected static ?string $pluralModelLabel = 'Ausstattung'; - protected static ?int $navigationSort = 3; + protected static ?int $navigationSort = 4; public static function form(Schema $schema): Schema { diff --git a/app/Filament/Resources/Appearances/AppearanceResource.php b/app/Filament/Resources/Appearances/AppearanceResource.php new file mode 100644 index 0000000..42efd94 --- /dev/null +++ b/app/Filament/Resources/Appearances/AppearanceResource.php @@ -0,0 +1,57 @@ + ListAppearances::route('/'), + 'create' => CreateAppearance::route('/create'), + 'edit' => EditAppearance::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/Appearances/Pages/CreateAppearance.php b/app/Filament/Resources/Appearances/Pages/CreateAppearance.php new file mode 100644 index 0000000..e4b608e --- /dev/null +++ b/app/Filament/Resources/Appearances/Pages/CreateAppearance.php @@ -0,0 +1,11 @@ +columns(2) + ->components([ + Section::make('Zeitraum') + ->description('Wiederholt sich jedes Jahr. Überschneiden sich Zeiträume, gilt die höhere Priorität (z. B. Silvester vor Winter). Ohne Zeitraum greift das Standard-Erscheinungsbild.') + ->columns(2) + ->schema([ + TextInput::make('name')->label('Name')->placeholder('z. B. Weihnachten')->required()->maxLength(60), + Select::make('site_id') + ->label('Website') + ->options(fn (): array => Site::query()->pluck('name', 'id')->all()) + ->default(fn (): ?int => Site::query()->where('is_default', true)->value('id')) + ->required(), + self::dayField('starts_md', 'Von (TT.MM.)'), + self::dayField('ends_md', 'Bis einschließlich (TT.MM.)'), + TextInput::make('priority')->label('Priorität')->integer()->minValue(0)->default(10), + Toggle::make('is_default')->label('Standard (wenn kein Zeitraum passt)')->inline(false), + Toggle::make('is_active')->label('Aktiv')->default(true)->inline(false), + ]), + Section::make('Bild & Angebot') + ->columns(2) + ->schema([ + Select::make('hero_photo_id') + ->label('Titelbild') + ->options(fn (): array => Photo::query()->orderBy('category')->orderBy('sort_order')->pluck('alt_text', 'id')->all()) + ->searchable() + ->placeholder('Bild der Seite verwenden'), + Select::make('featured_offer_id') + ->label('Hervorgehobenes Sonderangebot') + ->options(fn (): array => SpecialOffer::query()->where('is_active', true)->pluck('name', 'id')->all()) + ->placeholder('keins'), + ]), + Section::make('Texte') + ->description('Leer lassen = Text der Seite bzw. kein Banner.') + ->columns(2) + ->collapsible() + ->schema(collect(Appearance::OVERRIDABLE) + ->map(fn (string $label, string $key) => TextInput::make('overrides.'.$key)->label($label)->maxLength(255)) + ->values() + ->all()), + Section::make('Farben') + ->description('Nur ändern, was anders aussehen soll; leere Felder übernehmen die Farben des Themes.') + ->columns(3) + ->collapsible() + ->collapsed() + ->schema(fn (Get $get): array => self::tokenFields($get('site_id'))), + ]); + } + + /** + * @return list + */ + public static function tokenFields(int|string|null $siteId, string $statePath = 'tokens'): array + { + $theme = Site::find($siteId)?->theme ?? config('themes.base'); + + return collect(app(ThemeRegistry::class)->get($theme)->tokens) + ->map(fn (array $token, string $key): ColorPicker => ColorPicker::make("{$statePath}.{$key}")->label($token['label'])->placeholder($token['default'])) + ->values() + ->all(); + } + + /** + * Day of the year entered as "TT.MM." and stored as "MM-DD". + */ + private static function dayField(string $name, string $label): TextInput + { + return TextInput::make($name) + ->label($label) + ->placeholder('24.12.') + ->formatStateUsing(fn (?string $state): ?string => $state ? substr($state, 3, 2).'.'.substr($state, 0, 2).'.' : null) + ->dehydrateStateUsing(fn (?string $state): ?string => self::toMonthDay($state)) + ->rule(fn (): Closure => function (string $attribute, mixed $value, Closure $fail): void { + if (filled($value) && self::toMonthDay((string) $value) === null) { + $fail('Bitte als TT.MM. eingeben, z. B. 24.12.'); + } + }); + } + + private static function toMonthDay(?string $value): ?string + { + if (blank($value) || ! preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.?\s*$/', $value, $match)) { + return null; + } + + return checkdate((int) $match[2], (int) $match[1], 2024) ? sprintf('%02d-%02d', $match[2], $match[1]) : null; + } +} diff --git a/app/Filament/Resources/Appearances/Tables/AppearancesTable.php b/app/Filament/Resources/Appearances/Tables/AppearancesTable.php new file mode 100644 index 0000000..0c3833f --- /dev/null +++ b/app/Filament/Resources/Appearances/Tables/AppearancesTable.php @@ -0,0 +1,50 @@ +defaultSort('priority', 'desc') + ->description('Die Webseite wechselt automatisch nach Datum. Mit „Vorschau“ sehen Sie ein Erscheinungsbild schon vorher.') + ->columns([ + TextColumn::make('name')->label('Erscheinungsbild')->weight('medium'), + TextColumn::make('period') + ->label('Zeitraum') + ->state(fn (Appearance $record): string => $record->is_default && ! $record->starts_md ? 'Standard' : self::day($record->starts_md).' – '.self::day($record->ends_md)), + TextColumn::make('priority')->label('Priorität')->sortable(), + IconColumn::make('current') + ->label('Jetzt aktiv') + ->boolean() + ->state(fn (Appearance $record): bool => $record->site?->appearanceOn(today())?->is($record) ?? false), + ToggleColumn::make('is_active')->label('Aktiv'), + ]) + ->recordActions([ + Action::make('preview') + ->label('Vorschau') + ->icon(Heroicon::OutlinedEye) + ->color('gray') + ->url(fn (Appearance $record): string => URL::temporarySignedRoute('home', now()->addDay(), ['vorschau' => $record->id]), shouldOpenInNewTab: true), + EditAction::make(), + DeleteAction::make()->visible(fn (Appearance $record): bool => ! $record->is_default), + ]); + } + + private static function day(?string $monthDay): string + { + return $monthDay ? substr($monthDay, 3, 2).'.'.substr($monthDay, 0, 2).'.' : '?'; + } +} diff --git a/app/Filament/Resources/Faqs/FaqResource.php b/app/Filament/Resources/Faqs/FaqResource.php index ac44dd7..83c3341 100644 --- a/app/Filament/Resources/Faqs/FaqResource.php +++ b/app/Filament/Resources/Faqs/FaqResource.php @@ -27,7 +27,7 @@ class FaqResource extends Resource protected static ?string $pluralModelLabel = 'Häufige Fragen'; - protected static ?int $navigationSort = 4; + protected static ?int $navigationSort = 5; public static function form(Schema $schema): Schema { diff --git a/app/Filament/Resources/Notices/NoticeResource.php b/app/Filament/Resources/Notices/NoticeResource.php index 5edd9ec..57740c7 100644 --- a/app/Filament/Resources/Notices/NoticeResource.php +++ b/app/Filament/Resources/Notices/NoticeResource.php @@ -27,7 +27,7 @@ class NoticeResource extends Resource protected static ?string $pluralModelLabel = 'Hinweis-Banner'; - protected static ?int $navigationSort = 5; + protected static ?int $navigationSort = 6; public static function form(Schema $schema): Schema { diff --git a/app/Filament/Resources/Pages/PageResource.php b/app/Filament/Resources/Pages/PageResource.php new file mode 100644 index 0000000..fde69e3 --- /dev/null +++ b/app/Filament/Resources/Pages/PageResource.php @@ -0,0 +1,57 @@ + ListPages::route('/'), + 'create' => CreatePage::route('/create'), + 'edit' => EditPage::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/Pages/Pages/CreatePage.php b/app/Filament/Resources/Pages/Pages/CreatePage.php new file mode 100644 index 0000000..cea7659 --- /dev/null +++ b/app/Filament/Resources/Pages/Pages/CreatePage.php @@ -0,0 +1,11 @@ +columns(3) + ->components([ + Section::make('Bausteine') + ->description('Die Seite besteht aus Bausteinen. Reihenfolge per Ziehen, Inhalte je Baustein. Wie sie aussehen, bestimmt das Theme.') + ->columnSpan(2) + ->schema([ + Builder::make('sections') + ->hiddenLabel() + ->blocks(fn (): array => app(SectionRegistry::class)->blocks()) + ->addActionLabel('Baustein hinzufügen') + ->collapsible() + ->collapsed() + ->cloneable() + ->blockNumbers(false) + ->blockPickerColumns(2), + ]), + Section::make('Seite') + ->columnSpan(1) + ->schema([ + Hidden::make('site_id')->default(fn (): ?int => Site::query()->where('is_default', true)->value('id') ?? Site::query()->value('id')), + TextInput::make('title')->label('Titel')->required()->maxLength(120), + TextInput::make('slug') + ->label('Adresse') + ->prefix('/') + ->helperText('Die Startseite heißt „start“.') + ->required() + ->alphaDash() + ->maxLength(80) + ->disabled(fn (?Page $record): bool => $record?->isHome() ?? false) + ->dehydrated() + ->unique(ignoreRecord: true, modifyRuleUsing: fn (Unique $rule, callable $get) => $rule->where('site_id', $get('site_id'))), + TextInput::make('menu_label')->label('Name im Menü (optional)')->maxLength(60), + Select::make('menu_location')->label('Menü')->options(Page::MENU_LOCATIONS)->default('main')->required(), + Toggle::make('is_published')->label('Veröffentlicht')->default(true), + ]), + Section::make('Suchmaschinen') + ->columnSpan(1) + ->collapsed() + ->schema([ + TextInput::make('seo_title')->label('Seitentitel (Google)')->maxLength(70), + Textarea::make('seo_description')->label('Beschreibung (Google)')->rows(3)->maxLength(170), + ]), + ]); + } +} diff --git a/app/Filament/Resources/Pages/Tables/PagesTable.php b/app/Filament/Resources/Pages/Tables/PagesTable.php new file mode 100644 index 0000000..e1fa081 --- /dev/null +++ b/app/Filament/Resources/Pages/Tables/PagesTable.php @@ -0,0 +1,39 @@ +reorderable('sort_order') + ->defaultSort('sort_order') + ->paginated(false) + ->description('Reihenfolge per Ziehen = Reihenfolge im Menü.') + ->columns([ + TextColumn::make('title')->label('Seite')->weight('medium')->description(fn (Page $record): string => $record->isHome() ? '/' : '/'.$record->slug), + TextColumn::make('menu_location')->label('Menü')->formatStateUsing(fn (string $state): string => Page::MENU_LOCATIONS[$state] ?? $state)->badge(), + TextColumn::make('sections')->label('Bausteine')->state(fn (Page $record): int => count($record->sections ?? [])), + ToggleColumn::make('is_published')->label('Veröffentlicht'), + ]) + ->recordActions([ + Action::make('open') + ->label('Ansehen') + ->icon(Heroicon::OutlinedArrowTopRightOnSquare) + ->color('gray') + ->url(fn (Page $record): string => $record->url(), shouldOpenInNewTab: true), + EditAction::make(), + DeleteAction::make()->visible(fn (Page $record): bool => ! $record->isHome()), + ]); + } +} diff --git a/app/Filament/Resources/Photos/PhotoResource.php b/app/Filament/Resources/Photos/PhotoResource.php index 883656e..065281c 100644 --- a/app/Filament/Resources/Photos/PhotoResource.php +++ b/app/Filament/Resources/Photos/PhotoResource.php @@ -27,7 +27,7 @@ class PhotoResource extends Resource protected static ?string $pluralModelLabel = 'Bilder'; - protected static ?int $navigationSort = 1; + protected static ?int $navigationSort = 2; public static function form(Schema $schema): Schema { diff --git a/app/Filament/Resources/Properties/Schemas/PropertyForm.php b/app/Filament/Resources/Properties/Schemas/PropertyForm.php index cab3e13..d1d0ed5 100644 --- a/app/Filament/Resources/Properties/Schemas/PropertyForm.php +++ b/app/Filament/Resources/Properties/Schemas/PropertyForm.php @@ -3,6 +3,8 @@ namespace App\Filament\Resources\Properties\Schemas; use App\Filament\Forms\Components\EuroInput; +use App\Models\Site; +use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TimePicker; use Filament\Forms\Components\Toggle; @@ -46,6 +48,10 @@ public static function configure(Schema $schema): Schema TimePicker::make('check_out_time') ->label('Abreise bis') ->seconds(false), + Select::make('site_id') + ->label('Website') + ->options(fn (): array => Site::query()->pluck('name', 'id')->all()) + ->placeholder('keine'), Toggle::make('is_active') ->label('Aktiv (auf der Webseite buchbar)') ->default(true), diff --git a/app/Filament/Resources/Sites/Pages/CreateSite.php b/app/Filament/Resources/Sites/Pages/CreateSite.php new file mode 100644 index 0000000..e98951a --- /dev/null +++ b/app/Filament/Resources/Sites/Pages/CreateSite.php @@ -0,0 +1,11 @@ +columns(2) + ->components([ + Section::make('Website') + ->columns(2) + ->schema([ + TextInput::make('name')->label('Name')->required()->maxLength(120), + TextInput::make('domain') + ->label('Domain') + ->placeholder('www.fewo-stommer.de') + ->helperText('Leer = Standard-Website für alle Adressen ohne eigene Zuordnung.') + ->unique(ignoreRecord: true) + ->maxLength(190), + Select::make('theme')->label('Theme')->options(fn (): array => app(ThemeRegistry::class)->options())->default(config('themes.base'))->required()->live(), + Toggle::make('is_default')->label('Standard-Website')->inline(false), + ]), + Section::make('Farben des Themes') + ->description('Grundfarben dieser Website; saisonale Erscheinungsbilder können einzelne Farben zusätzlich ändern.') + ->columns(3) + ->collapsible() + ->schema(fn (Get $get, ?Site $record): array => AppearanceForm::tokenFields($record?->id, 'theme_settings.tokens')), + ]); + } +} diff --git a/app/Filament/Resources/Sites/SiteResource.php b/app/Filament/Resources/Sites/SiteResource.php new file mode 100644 index 0000000..8356e23 --- /dev/null +++ b/app/Filament/Resources/Sites/SiteResource.php @@ -0,0 +1,57 @@ + ListSites::route('/'), + 'create' => CreateSite::route('/create'), + 'edit' => EditSite::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/Sites/Tables/SitesTable.php b/app/Filament/Resources/Sites/Tables/SitesTable.php new file mode 100644 index 0000000..71714f9 --- /dev/null +++ b/app/Filament/Resources/Sites/Tables/SitesTable.php @@ -0,0 +1,27 @@ +columns([ + TextColumn::make('name')->label('Website')->weight('medium'), + TextColumn::make('domain')->label('Domain')->placeholder('alle übrigen Adressen'), + TextColumn::make('theme')->label('Theme')->formatStateUsing(fn (string $state): string => app(ThemeRegistry::class)->get($state)->name), + TextColumn::make('properties_count')->label('Wohnungen')->counts('properties'), + IconColumn::make('is_default')->label('Standard')->boolean(), + ]) + ->recordActions([ + EditAction::make(), + ]); + } +} diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php new file mode 100644 index 0000000..981d2ba --- /dev/null +++ b/app/Http/Controllers/PageController.php @@ -0,0 +1,97 @@ +show(Page::HOME); + } + + public function show(string $slug): View + { + abort_unless($this->theme()->site->exists, 404); + + $page = $this->theme()->site->pages() + ->where('slug', $slug) + ->where('is_published', true) + ->firstOrFail(); + + return view('theme::page', [ + 'page' => $page, + 'sections' => $this->sections->render($this->theme(), $page->sections), + 'title' => $page->isHome() ? null : ($page->seo_title ?: $page->title), + 'description' => $page->seo_description ?: ($page->isHome() ? Content::get('seo.home.description') : null), + 'ogImage' => $this->theme()->heroPhoto()?->url('lg') ?: null, + 'structuredData' => $page->isHome() ? $this->structuredData() : null, + ]); + } + + public function sitemap(): Response + { + $pages = $this->theme()->site->exists + ? $this->theme()->site->pages()->where('is_published', true)->get() + : collect(); + + return response()->view('sitemap', ['pages' => $pages], 200, ['Content-Type' => 'application/xml']); + } + + public function robots(): Response + { + return response(implode("\n", [ + 'User-agent: *', + 'Disallow: /admin', + 'Disallow: /livewire', + 'Disallow: /automation', + 'Disallow: /bewertung', + 'Disallow: /angebote', + 'Sitemap: '.route('sitemap'), + '', + ]), 200, ['Content-Type' => 'text/plain; charset=UTF-8']); + } + + /** + * schema.org data of the property for search engines. + * + * @return array|null + */ + private function structuredData(): ?array + { + $property = $this->theme()->property(); + if ($property === null) { + return null; + } + + return array_filter([ + '@context' => 'https://schema.org', + '@type' => 'VacationRental', + 'name' => $property->name, + 'url' => route('home'), + 'image' => $this->theme()->heroPhoto()?->url('lg') ?: null, + 'address' => ['@type' => 'PostalAddress', 'streetAddress' => str($property->address)->before(',')->trim()->toString(), 'addressLocality' => 'Kühlungsborn', 'postalCode' => '18225', 'addressCountry' => 'DE'], + 'containsPlace' => ['@type' => 'Accommodation', 'floorSize' => ['@type' => 'QuantitativeValue', 'value' => $property->size_sqm, 'unitCode' => 'MTK'], 'occupancy' => ['@type' => 'QuantitativeValue', 'maxValue' => $property->max_guests]], + 'telephone' => config('fewo.owner.phone'), + ]); + } +} diff --git a/app/Http/Middleware/ResolveTheme.php b/app/Http/Middleware/ResolveTheme.php new file mode 100644 index 0000000..b2a4980 --- /dev/null +++ b/app/Http/Middleware/ResolveTheme.php @@ -0,0 +1,24 @@ +instance(Theme::class, $this->factory->forRequest($request)->activate()); + + return $next($request); + } +} diff --git a/app/Livewire/BookingRequest.php b/app/Livewire/BookingRequest.php index a0332fe..d73e3a7 100644 --- a/app/Livewire/BookingRequest.php +++ b/app/Livewire/BookingRequest.php @@ -84,6 +84,7 @@ public function mount(?Property $property = null): void { $this->propertyId = ($property ?? Property::query()->where('is_active', true)->firstOrFail())->id; $this->month = CarbonImmutable::today()->format('Y-m'); + $this->prefillFromSearch(); $this->utm = collect(request()->only(['utm_source', 'utm_medium', 'utm_campaign'])) ->filter(fn ($value): bool => is_string($value) && $value !== '') ->map(fn (string $value): string => mb_substr($value, 0, 100)) @@ -314,6 +315,26 @@ private function stayRequest(): StayRequest ); } + /** + * Dates and guests from the availability search of the hero section (?anreise=…&abreise=…&personen=…). + */ + private function prefillFromSearch(): void + { + $arrival = rescue(fn () => CarbonImmutable::createFromFormat('!Y-m-d', (string) request()->query('anreise')) ?: null, null, false); + $departure = rescue(fn () => CarbonImmutable::createFromFormat('!Y-m-d', (string) request()->query('abreise')) ?: null, null, false); + + if ($arrival && $departure && $departure->greaterThan($arrival) && $arrival->greaterThanOrEqualTo(CarbonImmutable::today())) { + $this->arrival = $arrival->toDateString(); + $this->departure = $departure->toDateString(); + $this->month = $arrival->format('Y-m'); + } + + $guests = (int) request()->query('personen'); + if ($guests >= 1 && $guests <= $this->property->max_guests) { + $this->guests = $guests; + } + } + private function firstMonth(): CarbonImmutable { return CarbonImmutable::createFromFormat('!Y-m', $this->month); diff --git a/app/Models/Appearance.php b/app/Models/Appearance.php new file mode 100644 index 0000000..033fcaf --- /dev/null +++ b/app/Models/Appearance.php @@ -0,0 +1,95 @@ + */ + use HasFactory; + + /** + * Texts an appearance can replace, with their admin labels. Sections read them through Theme::text(). + */ + public const OVERRIDABLE = [ + 'banner.text' => 'Banner: Text', + 'banner.link_label' => 'Banner: Link-Text', + 'banner.link_url' => 'Banner: Link-Ziel', + 'hero.eyebrow' => 'Titelbereich: kleine Überschrift', + 'hero.title' => 'Titelbereich: Überschrift', + 'hero.text' => 'Titelbereich: Text', + 'cta.title' => 'Abschluss: Überschrift', + 'cta.text' => 'Abschluss: Text', + ]; + + /** + * Get the attributes that should be cast. + * + * @return array + */ + protected function casts(): array + { + return [ + 'is_default' => 'boolean', + 'is_active' => 'boolean', + 'tokens' => 'array', + 'overrides' => 'array', + ]; + } + + /** + * @return BelongsTo + */ + public function site(): BelongsTo + { + return $this->belongsTo(Site::class); + } + + /** + * @return BelongsTo + */ + public function heroPhoto(): BelongsTo + { + return $this->belongsTo(Photo::class, 'hero_photo_id'); + } + + /** + * @return BelongsTo + */ + public function featuredOffer(): BelongsTo + { + return $this->belongsTo(SpecialOffer::class, 'featured_offer_id'); + } + + public function covers(CarbonInterface $date): bool + { + if ($this->starts_md === null || $this->ends_md === null) { + return false; + } + + $day = $date->format('m-d'); + + return $this->starts_md <= $this->ends_md + ? $day >= $this->starts_md && $day <= $this->ends_md + : $day >= $this->starts_md || $day <= $this->ends_md; + } + + public function override(string $key): ?string + { + $value = data_get($this->overrides, $key); + + return filled($value) ? (string) $value : null; + } +} diff --git a/app/Models/Page.php b/app/Models/Page.php new file mode 100644 index 0000000..7238936 --- /dev/null +++ b/app/Models/Page.php @@ -0,0 +1,62 @@ + */ + use HasFactory; + + public const HOME = 'start'; + + /** Menu locations a page can appear in. */ + public const MENU_LOCATIONS = ['main' => 'Hauptmenü', 'footer' => 'Fußzeile', 'none' => 'Nicht im Menü']; + + /** + * Get the attributes that should be cast. + * + * @return array + */ + protected function casts(): array + { + return [ + 'is_published' => 'boolean', + 'sections' => 'array', + ]; + } + + /** + * @return BelongsTo + */ + public function site(): BelongsTo + { + return $this->belongsTo(Site::class); + } + + public function isHome(): bool + { + return $this->slug === self::HOME; + } + + public function url(): string + { + return $this->isHome() ? route('home') : route('page', ['slug' => $this->slug]); + } + + public function label(): string + { + return $this->menu_label ?: $this->title; + } +} diff --git a/app/Models/Property.php b/app/Models/Property.php index 68d95da..ecf2082 100644 --- a/app/Models/Property.php +++ b/app/Models/Property.php @@ -13,6 +13,7 @@ * A rentable holiday apartment. All money amounts are stored in euro cents. */ #[Fillable([ + 'site_id', 'name', 'slug', 'address', diff --git a/app/Models/Site.php b/app/Models/Site.php new file mode 100644 index 0000000..5f27cf3 --- /dev/null +++ b/app/Models/Site.php @@ -0,0 +1,81 @@ + */ + use HasFactory; + + /** + * Get the attributes that should be cast. + * + * @return array + */ + protected function casts(): array + { + return [ + 'is_default' => 'boolean', + 'theme_settings' => 'array', + ]; + } + + /** + * @return HasMany + */ + public function pages(): HasMany + { + return $this->hasMany(Page::class)->orderBy('sort_order'); + } + + /** + * @return HasMany + */ + public function appearances(): HasMany + { + return $this->hasMany(Appearance::class); + } + + /** + * @return HasMany + */ + public function properties(): HasMany + { + return $this->hasMany(Property::class); + } + + /** + * The property sections show when they do not name one (the first active property). + */ + public function primaryProperty(): ?Property + { + return $this->properties()->where('is_active', true)->orderBy('id')->first() + ?? Property::query()->where('is_active', true)->whereNull('site_id')->orderBy('id')->first(); + } + + /** + * The appearance in effect on $date: the active seasonal one with the highest priority, else the default. + */ + public function appearanceOn(CarbonInterface $date): ?Appearance + { + $appearances = $this->appearances()->where('is_active', true)->get(); + + return $appearances + ->filter(fn (Appearance $appearance): bool => $appearance->covers($date)) + ->sortByDesc('priority') + ->first() + ?? $appearances->firstWhere('is_default', true); + } +} diff --git a/app/Policies/AppearancePolicy.php b/app/Policies/AppearancePolicy.php new file mode 100644 index 0000000..9724cec --- /dev/null +++ b/app/Policies/AppearancePolicy.php @@ -0,0 +1,13 @@ +app->singleton(ThemeRegistry::class); + $this->app->singleton(SectionRegistry::class); + + // Outside web requests (console, tests, mails) the default site's theme is used. + $this->app->singleton(Theme::class, fn ($app): Theme => $app->make(ThemeFactory::class) + ->forSite($app->make(ThemeFactory::class)->site()) + ->activate()); + } +} diff --git a/app/Support/Content.php b/app/Support/Content.php index b1cb06d..b1b85f9 100644 --- a/app/Support/Content.php +++ b/app/Support/Content.php @@ -32,7 +32,9 @@ public static function get(string $key): ?string */ public static function html(string $key): HtmlString { - return new HtmlString(RichContentRenderer::make(self::get($key) ?? '')->toHtml()); + $value = self::get($key); + + return new HtmlString(filled($value) ? RichContentRenderer::make($value)->toHtml() : ''); } public static function photo(string $key): ?Photo diff --git a/app/Themes/SectionRegistry.php b/app/Themes/SectionRegistry.php new file mode 100644 index 0000000..c71297a --- /dev/null +++ b/app/Themes/SectionRegistry.php @@ -0,0 +1,71 @@ +> + */ + public function all(): array + { + return collect(config('themes.sections')) + ->mapWithKeys(fn (string $class): array => [$class::key() => $class]) + ->all(); + } + + public function get(string $key): ?Section + { + $class = $this->all()[$key] ?? null; + + return $class ? app($class) : null; + } + + /** + * @return list + */ + public function blocks(): array + { + return array_values(array_map( + fn (string $class): Block => Block::make($class::key()) + ->label($class::label()) + ->icon($class::icon()) + ->schema($class::schema()), + $this->all(), + )); + } + + /** + * Renders the stored sections of a page; unknown or failing types are skipped (and reported), + * so a page never breaks because of one section. + * + * @param list}>|null $sections + * @return list + */ + public function render(Theme $theme, ?array $sections): array + { + $views = []; + foreach ($sections ?? [] as $index => $stored) { + $section = $this->get($stored['type'] ?? ''); + if ($section === null || ! ViewFactory::exists($section->view())) { + continue; + } + + $views[] = ViewFactory::make($section->view(), [ + ...$section->data($theme, $stored['data'] ?? []), + 'theme' => $theme, + 'sectionId' => $section::key().'-'.$index, + ]); + } + + return $views; + } +} diff --git a/app/Themes/Sections/AmenitiesSection.php b/app/Themes/Sections/AmenitiesSection.php new file mode 100644 index 0000000..57a6924 --- /dev/null +++ b/app/Themes/Sections/AmenitiesSection.php @@ -0,0 +1,48 @@ +label('Überschrift')->default('Ausstattung')->maxLength(120), + Toggle::make('highlights_only')->label('Nur Highlights zeigen'), + ]; + } + + public function data(Theme $theme, array $data): array + { + $amenities = $theme->property()?->amenities() + ->when($data['highlights_only'] ?? false, fn ($query) => $query->where('is_highlight', true)) + ->get() ?? collect(); + + return [ + 'heading' => $data['heading'] ?? 'Ausstattung', + 'groups' => $amenities->groupBy(fn ($amenity): string => $amenity->area->getLabel()), + ]; + } +} diff --git a/app/Themes/Sections/BookingSection.php b/app/Themes/Sections/BookingSection.php new file mode 100644 index 0000000..5a923c7 --- /dev/null +++ b/app/Themes/Sections/BookingSection.php @@ -0,0 +1,45 @@ +label('Überschrift')->default('Preise & Buchung')->maxLength(120), + Textarea::make('text')->label('Text')->rows(2), + ]; + } + + public function data(Theme $theme, array $data): array + { + return [ + 'heading' => $data['heading'] ?? null, + 'text' => $data['text'] ?? null, + 'property' => $theme->property(), + ]; + } +} diff --git a/app/Themes/Sections/CallToActionSection.php b/app/Themes/Sections/CallToActionSection.php new file mode 100644 index 0000000..877cb9f --- /dev/null +++ b/app/Themes/Sections/CallToActionSection.php @@ -0,0 +1,51 @@ +label('Überschrift')->required()->maxLength(160), + Textarea::make('text')->label('Text')->rows(2), + static::photoSelect('photo_id', 'Hintergrundfoto'), + TextInput::make('button_label')->label('Button-Text')->default('Belegung & Preise')->maxLength(60), + static::pageSelect('button_page', 'Button führt zu'), + ]; + } + + public function data(Theme $theme, array $data): array + { + return [ + 'title' => $theme->text('cta.title', $data['title'] ?? null), + 'text' => $theme->text('cta.text', $data['text'] ?? null), + 'photo' => isset($data['photo_id']) ? Photo::find($data['photo_id']) : null, + 'buttonLabel' => $data['button_label'] ?? 'Belegung & Preise', + 'buttonUrl' => $this->pageUrl($data['button_page'] ?? null) ?? route('booking.create'), + ]; + } +} diff --git a/app/Themes/Sections/ContactSection.php b/app/Themes/Sections/ContactSection.php new file mode 100644 index 0000000..3a51a5e --- /dev/null +++ b/app/Themes/Sections/ContactSection.php @@ -0,0 +1,46 @@ +label('Überschrift')->default('Kontakt')->maxLength(120), + Textarea::make('text')->label('Text')->rows(2), + ]; + } + + public function data(Theme $theme, array $data): array + { + return [ + 'heading' => $data['heading'] ?? null, + 'text' => $data['text'] ?? null, + 'owner' => config('fewo.owner'), + 'address' => $theme->property()?->address, + ]; + } +} diff --git a/app/Themes/Sections/FactsSection.php b/app/Themes/Sections/FactsSection.php new file mode 100644 index 0000000..f41929f --- /dev/null +++ b/app/Themes/Sections/FactsSection.php @@ -0,0 +1,46 @@ +label('Überschrift (optional)')->maxLength(120), + ]; + } + + public function data(Theme $theme, array $data): array + { + $property = $theme->property(); + + return [ + 'heading' => $data['heading'] ?? null, + 'property' => $property, + 'highlights' => $property?->amenities()->where('is_highlight', true)->limit(6)->pluck('name') ?? collect(), + 'fromPrice' => $property?->seasons()->whereDate('ends_on', '>', today())->min('nightly_rate'), + ]; + } +} diff --git a/app/Themes/Sections/FaqSection.php b/app/Themes/Sections/FaqSection.php new file mode 100644 index 0000000..9629062 --- /dev/null +++ b/app/Themes/Sections/FaqSection.php @@ -0,0 +1,46 @@ +label('Überschrift')->default('Häufige Fragen')->maxLength(120), + ]; + } + + public function data(Theme $theme, array $data): array + { + $faqs = Faq::query()->published()->get(); + + return [ + 'heading' => $data['heading'] ?? null, + 'faqs' => $faqs, + 'answers' => $faqs->mapWithKeys(fn (Faq $faq): array => [$faq->id => $this->html($faq->answer)]), + ]; + } +} diff --git a/app/Themes/Sections/GallerySection.php b/app/Themes/Sections/GallerySection.php new file mode 100644 index 0000000..41c4802 --- /dev/null +++ b/app/Themes/Sections/GallerySection.php @@ -0,0 +1,52 @@ +label('Überschrift')->maxLength(120), + Select::make('category')->label('Bilder')->options(['all' => 'Alle', ...collect(PhotoCategory::cases())->mapWithKeys(fn (PhotoCategory $category): array => [$category->value => $category->getLabel()])->all()])->default('all'), + TextInput::make('limit')->label('Anzahl (leer = alle)')->integer()->minValue(1), + ]; + } + + public function data(Theme $theme, array $data): array + { + $category = PhotoCategory::tryFrom($data['category'] ?? ''); + + return [ + 'heading' => $data['heading'] ?? null, + 'photos' => Photo::query()->published()->with('media') + ->when($category, fn ($query) => $query->where('category', $category)) + ->when(filled($data['limit'] ?? null), fn ($query) => $query->limit((int) $data['limit'])) + ->get(), + ]; + } +} diff --git a/app/Themes/Sections/HeroSection.php b/app/Themes/Sections/HeroSection.php new file mode 100644 index 0000000..c816db2 --- /dev/null +++ b/app/Themes/Sections/HeroSection.php @@ -0,0 +1,55 @@ +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_id', 'Foto (wenn das Erscheinungsbild keins vorgibt)'), + Toggle::make('show_search')->label('Verfügbarkeitssuche anzeigen')->default(true), + ]; + } + + public function data(Theme $theme, array $data): array + { + $fallback = isset($data['photo_id']) ? Photo::find($data['photo_id']) : Photo::query()->published()->first(); + + 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' => $theme->heroPhoto($fallback), + 'showSearch' => (bool) ($data['show_search'] ?? true), + 'property' => $theme->property(), + ]; + } +} diff --git a/app/Themes/Sections/HostSection.php b/app/Themes/Sections/HostSection.php new file mode 100644 index 0000000..6e12781 --- /dev/null +++ b/app/Themes/Sections/HostSection.php @@ -0,0 +1,46 @@ +label('Kleine Überschrift')->default('Ihre Gastgeberin')->maxLength(100), + ]; + } + + public function data(Theme $theme, array $data): array + { + return [ + 'heading' => $data['heading'] ?? null, + 'quote' => Content::get('host.quote'), + 'text' => Content::html('host.text'), + 'photo' => Content::photo('host.photo'), + 'name' => config('fewo.owner.name'), + ]; + } +} diff --git a/app/Themes/Sections/LocationSection.php b/app/Themes/Sections/LocationSection.php new file mode 100644 index 0000000..fa5ea78 --- /dev/null +++ b/app/Themes/Sections/LocationSection.php @@ -0,0 +1,57 @@ +label('Kleine Überschrift')->maxLength(100), + TextInput::make('heading')->label('Überschrift')->required()->maxLength(160), + RichEditor::make('text')->label('Text')->toolbarButtons([['bold', 'italic', 'link'], ['bulletList']]), + Toggle::make('show_photos')->label('Bilder der Umgebung zeigen')->default(true), + ]; + } + + public function data(Theme $theme, array $data): array + { + $address = $theme->property()?->address; + + return [ + 'eyebrow' => $data['eyebrow'] ?? null, + 'heading' => $data['heading'] ?? '', + 'text' => $this->html($data['text'] ?? null), + 'address' => $address, + 'mapUrl' => $address ? 'https://www.openstreetmap.org/search?query='.rawurlencode($address) : null, + 'photos' => ($data['show_photos'] ?? true) + ? Photo::query()->published()->with('media')->where('category', PhotoCategory::Area)->limit(6)->get() + : collect(), + ]; + } +} diff --git a/app/Themes/Sections/OffersSection.php b/app/Themes/Sections/OffersSection.php new file mode 100644 index 0000000..5fbe0db --- /dev/null +++ b/app/Themes/Sections/OffersSection.php @@ -0,0 +1,56 @@ +label('Überschrift')->default('Aktuelle Angebote')->maxLength(120), + ]; + } + + public function data(Theme $theme, array $data): array + { + $offers = $theme->property()?->specialOffers() + ->active() + ->where('is_public', true) + ->whereNull('code') + ->where(fn ($query) => $query->whereNull('bookable_until')->orWhere('bookable_until', '>=', now())) + ->get() ?? collect(); + + $featured = $theme->appearance?->featuredOffer; + if ($featured) { + $offers = $offers->reject(fn (SpecialOffer $offer): bool => $offer->is($featured))->prepend($featured); + } + + return [ + 'heading' => $data['heading'] ?? null, + 'offers' => $offers, + 'featuredId' => $featured?->id, + ]; + } +} diff --git a/app/Themes/Sections/PricesSection.php b/app/Themes/Sections/PricesSection.php new file mode 100644 index 0000000..56caae9 --- /dev/null +++ b/app/Themes/Sections/PricesSection.php @@ -0,0 +1,52 @@ +label('Kleine Überschrift')->default('Preise')->maxLength(100), + TextInput::make('heading')->label('Überschrift')->default('Transparent, ohne Überraschungen.')->maxLength(160), + Textarea::make('text')->label('Text')->rows(2), + ]; + } + + public function data(Theme $theme, array $data): array + { + $property = $theme->property(); + + return [ + 'eyebrow' => $data['eyebrow'] ?? null, + 'heading' => $data['heading'] ?? '', + 'text' => $data['text'] ?? null, + 'property' => $property, + 'seasons' => $property?->seasons()->whereDate('ends_on', '>', today())->whereDate('starts_on', '<', today()->addYear())->get() ?? collect(), + 'extras' => $property?->extras()->active()->get() ?? collect(), + 'featuredSeason' => $theme->appearance?->name, + ]; + } +} diff --git a/app/Themes/Sections/ReviewsSection.php b/app/Themes/Sections/ReviewsSection.php new file mode 100644 index 0000000..548dd80 --- /dev/null +++ b/app/Themes/Sections/ReviewsSection.php @@ -0,0 +1,53 @@ +label('Überschrift')->default('Das sagen unsere Gäste')->maxLength(120), + TextInput::make('limit')->label('Anzahl')->integer()->minValue(1)->default(6), + ]; + } + + public function data(Theme $theme, array $data): array + { + $published = Review::query()->published() + ->when($theme->property(), fn ($query, $property) => $query->whereBelongsTo($property)); + + return [ + 'heading' => $data['heading'] ?? null, + 'reviews' => (clone $published)->limit((int) ($data['limit'] ?? 6))->get(), + 'count' => (clone $published)->count(), + 'average' => round((float) (clone $published)->avg('rating'), 1), + 'categories' => collect(Review::CATEGORIES) + ->map(fn (string $label, string $field): array => ['label' => $label, 'average' => round((float) (clone $published)->avg($field), 1)]) + ->filter(fn (array $category): bool => $category['average'] > 0) + ->values(), + ]; + } +} diff --git a/app/Themes/Sections/RichTextSection.php b/app/Themes/Sections/RichTextSection.php new file mode 100644 index 0000000..896cad4 --- /dev/null +++ b/app/Themes/Sections/RichTextSection.php @@ -0,0 +1,64 @@ + 'Eigener Text', + 'legal.imprint' => 'Impressum (Texte › Rechtliches)', + 'legal.privacy' => 'Datenschutzerklärung (Texte › Rechtliches)', + 'stay.house_rules' => 'Hausregeln (Texte › Aufenthalt)', + 'stay.cancellation' => 'Stornobedingungen (Texte › Aufenthalt)', + ]; + + public static function key(): string + { + return 'rich_text'; + } + + public static function label(): string + { + return 'Fließtext'; + } + + public static function icon(): string + { + return 'heroicon-o-bars-3-bottom-left'; + } + + public static function schema(): array + { + return [ + TextInput::make('heading')->label('Überschrift')->maxLength(160), + Select::make('source')->label('Inhalt')->options(self::SOURCES)->default('own')->live(), + RichEditor::make('text') + ->label('Text') + ->visible(fn (Get $get): bool => ($get('source') ?? 'own') === 'own') + ->toolbarButtons([['bold', 'italic', 'link'], ['h2', 'h3'], ['bulletList', 'orderedList']]), + ]; + } + + public function data(Theme $theme, array $data): array + { + $source = $data['source'] ?? 'own'; + + return [ + 'heading' => $data['heading'] ?? null, + 'text' => $source === 'own' || ! array_key_exists($source, self::SOURCES) + ? $this->html($data['text'] ?? null) + : (filled(Content::get($source)) ? Content::html($source) : null), + ]; + } +} diff --git a/app/Themes/Sections/Section.php b/app/Themes/Sections/Section.php new file mode 100644 index 0000000..4879ff5 --- /dev/null +++ b/app/Themes/Sections/Section.php @@ -0,0 +1,109 @@ +". Register new sections in config/themes.php. + */ +abstract class Section +{ + abstract public static function key(): string; + + abstract public static function label(): string; + + /** + * Heroicon name shown in the page builder. + */ + public static function icon(): string + { + return 'heroicon-o-square-3-stack-3d'; + } + + /** + * Admin fields of the section (builder block schema). Field names are keys of $data in data(). + * + * @return list + */ + public static function schema(): array + { + return []; + } + + /** + * Variables for the view. + * + * @param array $data what the admin entered + * @return array + */ + abstract public function data(Theme $theme, array $data): array; + + public function view(): string + { + return 'theme::sections.'.static::key(); + } + + /** + * Sanitised HTML of a rich text field. + */ + protected function html(?string $value): ?HtmlString + { + return filled($value) ? new HtmlString(RichContentRenderer::make($value)->toHtml()) : null; + } + + /** + * @param list|null $ids + * @return Collection + */ + protected function photos(?array $ids): Collection + { + if (blank($ids)) { + return new Collection; + } + + $photos = Photo::query()->published()->whereKey($ids)->with('media')->get()->keyBy('id'); + + return new Collection(array_values(array_filter(array_map(fn ($id) => $photos->get((int) $id), $ids)))); + } + + protected function pageUrl(?string $slug): ?string + { + if (blank($slug)) { + return null; + } + + return $slug === Page::HOME ? route('home') : route('page', ['slug' => $slug]); + } + + /** + * Select field listing the website photos. + */ + protected static function photoSelect(string $name, string $label, bool $multiple = false): Select + { + return Select::make($name) + ->label($label) + ->options(fn (): array => Photo::query()->orderBy('category')->orderBy('sort_order')->pluck('alt_text', 'id')->all()) + ->multiple($multiple) + ->searchable(); + } + + /** + * Select field listing the pages of the site, for links. + */ + protected static function pageSelect(string $name, string $label): Select + { + return Select::make($name) + ->label($label) + ->options(fn (): array => Page::query()->orderBy('sort_order')->pluck('title', 'slug')->all()) + ->searchable(); + } +} diff --git a/app/Themes/Sections/TextImageSection.php b/app/Themes/Sections/TextImageSection.php new file mode 100644 index 0000000..0e34157 --- /dev/null +++ b/app/Themes/Sections/TextImageSection.php @@ -0,0 +1,55 @@ +label('Kleine Überschrift')->maxLength(100), + TextInput::make('heading')->label('Überschrift')->required()->maxLength(160), + RichEditor::make('text')->label('Text')->toolbarButtons([['bold', 'italic', 'link'], ['bulletList', 'orderedList']]), + static::photoSelect('photo_ids', 'Bilder (bis zu 3)', multiple: true)->maxItems(3), + Select::make('image_position')->label('Bilder')->options(['right' => 'rechts', 'left' => 'links'])->default('right'), + TextInput::make('link_label')->label('Link-Text')->maxLength(80), + static::pageSelect('link_page', 'Link zur Seite'), + ]; + } + + public function data(Theme $theme, array $data): array + { + return [ + 'eyebrow' => $data['eyebrow'] ?? null, + 'heading' => $data['heading'] ?? '', + 'text' => $this->html($data['text'] ?? null), + 'photos' => $this->photos($data['photo_ids'] ?? []), + 'imagePosition' => $data['image_position'] ?? 'right', + 'linkLabel' => $data['link_label'] ?? null, + 'linkUrl' => $this->pageUrl($data['link_page'] ?? null), + ]; + } +} diff --git a/app/Themes/Theme.php b/app/Themes/Theme.php new file mode 100644 index 0000000..d295ec6 --- /dev/null +++ b/app/Themes/Theme.php @@ -0,0 +1,142 @@ +> */ + private array $menus = []; + + public function __construct( + private ThemeRegistry $registry, + public readonly Site $site, + public readonly ?Appearance $appearance, + public readonly bool $isPreview = false, + ) {} + + public function activate(): self + { + $paths = array_map(fn (ThemeManifest $theme): string => $theme->viewsPath(), $this->chain()); + View::replaceNamespace('theme', $paths); + + return $this; + } + + public function manifest(): ThemeManifest + { + return $this->registry->get($this->site->theme ?: config('themes.base')); + } + + /** + * @return list + */ + public function chain(): array + { + return $this->registry->chain($this->manifest()->key); + } + + /** + * Colour tokens: theme defaults (base first, then children), site settings, appearance. + * + * @return array + */ + public function tokens(): array + { + $tokens = []; + foreach (array_reverse($this->chain()) as $theme) { + foreach ($theme->tokens as $key => $token) { + $tokens[$key] = $token['default']; + } + } + + $overrides = [...($this->site->theme_settings['tokens'] ?? []), ...($this->appearance?->tokens ?? [])]; + foreach ($overrides as $key => $value) { + if (isset($tokens[$key]) && is_string($value) && preg_match('/^#[0-9a-fA-F]{3,8}$/', $value)) { + $tokens[$key] = $value; + } + } + + return $tokens; + } + + /** + * ":root{--ground:#F6F2EA;…}" for an inline + @livewireStyles + @stack('head') + + + Zum Inhalt springen + + @if ($theme->isPreview) +
Vorschau des Erscheinungsbilds „{{ $theme->appearance?->name }}“
+ @endif + + @include('theme::partials.banner') + @include('theme::partials.header') + +
+ @yield('content') +
+ + @include('theme::partials.footer') + @include('theme::partials.mobile-booking-bar') + + +
+ +
+ +
+
+ + @livewireScripts + + diff --git a/resources/themes/ostsee-licht/views/page.blade.php b/resources/themes/ostsee-licht/views/page.blade.php new file mode 100644 index 0000000..9c63237 --- /dev/null +++ b/resources/themes/ostsee-licht/views/page.blade.php @@ -0,0 +1,18 @@ +@extends('theme::layouts.app') + +@if ($structuredData) + @push('head') + + @endpush +@endif + +@section('content') + @forelse ($sections as $section) + {!! $section->render() !!} + @empty +
+

{{ $page->title }}

+

Diese Seite hat noch keine Inhalte.

+
+ @endforelse +@endsection diff --git a/resources/themes/ostsee-licht/views/partials/banner.blade.php b/resources/themes/ostsee-licht/views/partials/banner.blade.php new file mode 100644 index 0000000..c38c961 --- /dev/null +++ b/resources/themes/ostsee-licht/views/partials/banner.blade.php @@ -0,0 +1,11 @@ +@php($bannerText = $theme->text('banner.text', \App\Models\Notice::query()->visible()->latest()->value('text'))) +@if ($bannerText) +
+
+ {{ $bannerText }} + @if ($theme->text('banner.link_label')) + {{ $theme->text('banner.link_label') }} + @endif +
+
+@endif diff --git a/resources/themes/ostsee-licht/views/partials/footer.blade.php b/resources/themes/ostsee-licht/views/partials/footer.blade.php new file mode 100644 index 0000000..5df684f --- /dev/null +++ b/resources/themes/ostsee-licht/views/partials/footer.blade.php @@ -0,0 +1,19 @@ + diff --git a/resources/themes/ostsee-licht/views/partials/header.blade.php b/resources/themes/ostsee-licht/views/partials/header.blade.php new file mode 100644 index 0000000..f172493 --- /dev/null +++ b/resources/themes/ostsee-licht/views/partials/header.blade.php @@ -0,0 +1,29 @@ +
+ +
diff --git a/resources/themes/ostsee-licht/views/partials/image.blade.php b/resources/themes/ostsee-licht/views/partials/image.blade.php new file mode 100644 index 0000000..52a63aa --- /dev/null +++ b/resources/themes/ostsee-licht/views/partials/image.blade.php @@ -0,0 +1,14 @@ +{{-- + Responsive photo. Variables: $photo (App\Models\Photo|null), $class, $sizes (default 100vw), $eager (bool). +--}} +@if ($photo && $photo->url('md')) + {{ $photo->alt_text }} +@else + +@endif diff --git a/resources/themes/ostsee-licht/views/partials/mobile-booking-bar.blade.php b/resources/themes/ostsee-licht/views/partials/mobile-booking-bar.blade.php new file mode 100644 index 0000000..fa662a9 --- /dev/null +++ b/resources/themes/ostsee-licht/views/partials/mobile-booking-bar.blade.php @@ -0,0 +1,6 @@ +@unless (request()->routeIs('booking.create')) + + +@endunless diff --git a/resources/themes/ostsee-licht/views/sections/amenities.blade.php b/resources/themes/ostsee-licht/views/sections/amenities.blade.php new file mode 100644 index 0000000..7868beb --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/amenities.blade.php @@ -0,0 +1,17 @@ +@if ($groups->isNotEmpty()) +
+

{{ $heading }}

+
+ @foreach ($groups as $area => $amenities) +
+

{{ $area }}

+
    + @foreach ($amenities as $amenity) +
  • {{ $amenity->name }}
  • + @endforeach +
+
+ @endforeach +
+
+@endif diff --git a/resources/themes/ostsee-licht/views/sections/booking.blade.php b/resources/themes/ostsee-licht/views/sections/booking.blade.php new file mode 100644 index 0000000..7f6912b --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/booking.blade.php @@ -0,0 +1,11 @@ +
+ @if ($heading)

{{ $heading }}

@endif + @if ($text)

{{ $text }}

@endif +
+ @if ($property) + + @else +

Derzeit ist keine Wohnung buchbar.

+ @endif +
+
diff --git a/resources/themes/ostsee-licht/views/sections/contact.blade.php b/resources/themes/ostsee-licht/views/sections/contact.blade.php new file mode 100644 index 0000000..8daaaa9 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/contact.blade.php @@ -0,0 +1,22 @@ +
+

{{ $heading }}

+ @if ($text)

{{ $text }}

@endif +
+
+

Gastgeberin

+

{{ $owner['name'] }}

+

{{ $owner['street'] }}
{{ $owner['city'] }}

+

+ {{ $owner['phone'] }} + {{ $owner['email'] }} +

+
+ @if ($address) +
+

Ferienwohnung

+

{{ $address }}

+ Freie Termine & Preise +
+ @endif +
+
diff --git a/resources/themes/ostsee-licht/views/sections/cta.blade.php b/resources/themes/ostsee-licht/views/sections/cta.blade.php new file mode 100644 index 0000000..6eea002 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/cta.blade.php @@ -0,0 +1,10 @@ +
+ @include('theme::partials.image', ['photo' => $photo, 'class' => 'h-[28rem] w-full object-cover sm:h-[32rem]']) +
+
+

{{ $title }}

+ @if ($text)

{{ $text }}

@endif + {{ $buttonLabel }} +
+
+
diff --git a/resources/themes/ostsee-licht/views/sections/facts.blade.php b/resources/themes/ostsee-licht/views/sections/facts.blade.php new file mode 100644 index 0000000..8b97e12 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/facts.blade.php @@ -0,0 +1,17 @@ +
+ @if ($heading)

{{ $heading }}

@endif +
    + @if ($property?->size_sqm) +
  • {{ $property->size_sqm }} m²Wohnfläche
  • + @endif + @if ($property) +
  • 1–{{ $property->max_guests }}Gäste
  • + @endif + @if ($fromPrice) +
  • ab {{ \App\Support\Money::format((int) $fromPrice) }}pro Nacht
  • + @endif + @if ($highlights->isNotEmpty()) +
  • inklusive{{ $highlights->take(3)->implode(', ') }}
  • + @endif +
+
diff --git a/resources/themes/ostsee-licht/views/sections/faq.blade.php b/resources/themes/ostsee-licht/views/sections/faq.blade.php new file mode 100644 index 0000000..4d01345 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/faq.blade.php @@ -0,0 +1,24 @@ +@if ($faqs->isNotEmpty()) +
+

{{ $heading }}

+
+ @foreach ($faqs as $faq) +
+ + {{ $faq->question }} + + +
{{ $answers[$faq->id] }}
+
+ @endforeach +
+
+ + @push('head') + + @endpush +@endif diff --git a/resources/themes/ostsee-licht/views/sections/gallery.blade.php b/resources/themes/ostsee-licht/views/sections/gallery.blade.php new file mode 100644 index 0000000..cb0c8d6 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/gallery.blade.php @@ -0,0 +1,18 @@ +@if ($photos->isNotEmpty()) +
+ @if ($heading)

{{ $heading }}

@endif + +
+@endif diff --git a/resources/themes/ostsee-licht/views/sections/hero.blade.php b/resources/themes/ostsee-licht/views/sections/hero.blade.php new file mode 100644 index 0000000..d48d29b --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/hero.blade.php @@ -0,0 +1,32 @@ +
+
+ @include('theme::partials.image', ['photo' => $photo, 'class' => 'h-[30rem] w-full object-cover sm:h-[40rem]', 'eager' => true]) +
+ @if ($eyebrow)

{{ $eyebrow }}

@endif +

{!! preg_replace('/\*(.+?)\*/u', '$1', e($title)) !!}

+ @if ($text)

{{ $text }}

@endif +
+
+
+ +@if ($showSearch) +
+
+ + + + +
+
+@endif diff --git a/resources/themes/ostsee-licht/views/sections/host.blade.php b/resources/themes/ostsee-licht/views/sections/host.blade.php new file mode 100644 index 0000000..b70c9f7 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/host.blade.php @@ -0,0 +1,13 @@ +
+ @if ($photo) +
+ @include('theme::partials.image', ['photo' => $photo, 'sizes' => '22rem', 'class' => 'aspect-[4/5] w-full rounded object-cover']) +
+ @endif +
+ @if ($heading)

{{ $heading }}

@endif + @if ($quote)
„{{ $quote }}“
@endif +

{{ $name }}

+ @if ($text)
{{ $text }}
@endif +
+
diff --git a/resources/themes/ostsee-licht/views/sections/location.blade.php b/resources/themes/ostsee-licht/views/sections/location.blade.php new file mode 100644 index 0000000..1a0a509 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/location.blade.php @@ -0,0 +1,24 @@ +
+
+
+ @if ($eyebrow)

{{ $eyebrow }}

@endif +

{{ $heading }}

+ @if ($text)
{{ $text }}
@endif + @if ($address) +

{{ $address }}
+ Auf der Karte ansehen +

+ @endif +
+ @if ($photos->isNotEmpty()) +
+ @foreach ($photos->take(3) as $photo) +
+ @include('theme::partials.image', ['photo' => $photo, 'sizes' => '(min-width: 1024px) 18vw, 45vw', 'class' => 'h-48 w-full rounded-sm object-cover sm:h-64']) +
{{ $photo->caption ?: $photo->alt_text }}
+
+ @endforeach +
+ @endif +
+
diff --git a/resources/themes/ostsee-licht/views/sections/offers.blade.php b/resources/themes/ostsee-licht/views/sections/offers.blade.php new file mode 100644 index 0000000..766f204 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/offers.blade.php @@ -0,0 +1,17 @@ +@if ($offers->isNotEmpty()) +
+

{{ $heading }}

+
    + @foreach ($offers as $offer) +
  • $offer->id === $featuredId])> +

    {{ $offer->name }}

    + @if ($offer->public_description)

    {{ $offer->public_description }}

    @endif + @if ($offer->stay_from || $offer->stay_until) +

    Reisezeitraum {{ $offer->stay_from?->format('d.m.Y') ?? 'ab sofort' }} – {{ $offer->stay_until?->format('d.m.Y') ?? 'offen' }}

    + @endif +
  • + @endforeach +
+

Angebote werden bei der Preisberechnung automatisch berücksichtigt.

+
+@endif diff --git a/resources/themes/ostsee-licht/views/sections/prices.blade.php b/resources/themes/ostsee-licht/views/sections/prices.blade.php new file mode 100644 index 0000000..2b5837f --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/prices.blade.php @@ -0,0 +1,35 @@ +
+
+ @if ($eyebrow)

{{ $eyebrow }}

@endif +

{{ $heading }}

+ @if ($text)

{{ $text }}

@endif + @if ($property) +

+ Endreinigung & Service {{ \App\Support\Money::format($property->cleaning_fee) }} einmalig + @if ($property->extra_guest_fee_per_night) · ab der {{ $property->included_guests + 1 }}. Person {{ \App\Support\Money::format($property->extra_guest_fee_per_night) }} pro Nacht @endif + · Kurtaxe vor Ort. +

+ @if ($extras->isNotEmpty()) +

Auf Wunsch: {{ $extras->map(fn ($extra) => $extra->name.' '.\App\Support\Money::format($extra->price))->implode(' · ') }}

+ @endif + @endif + Freie Termine & Gesamtpreis +
+
+ + + + + + + @foreach ($seasons as $season) + $featuredSeason && str_contains(mb_strtolower($featuredSeason), mb_strtolower($season->name))])> + + + + + @endforeach + +
Preise pro Nacht nach Saison
SaisonZeitraumpro Nacht
{{ $season->name }}ab {{ $season->min_nights }} Nächten{{ $season->starts_on->format('d.m.') }} – {{ $season->ends_on->format('d.m.Y') }}{{ \App\Support\Money::format($season->nightly_rate) }}
+
+
diff --git a/resources/themes/ostsee-licht/views/sections/reviews.blade.php b/resources/themes/ostsee-licht/views/sections/reviews.blade.php new file mode 100644 index 0000000..d93181a --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/reviews.blade.php @@ -0,0 +1,31 @@ +@if ($reviews->isNotEmpty()) +
+
+

{{ $heading }}

+

{{ number_format($average, 1, ',', '') }} von 5 · {{ $count }} {{ $count === 1 ? 'Bewertung' : 'Bewertungen' }}

+
+ @if ($categories->isNotEmpty()) +
+ @foreach ($categories as $category) +
{{ $category['label'] }}
{{ number_format($category['average'], 1, ',', '') }}
+ @endforeach +
+ @endif +
    + @foreach ($reviews as $review) +
  • +
    +

    {{ str_repeat('★', $review->rating) }}{{ str_repeat('★', 5 - $review->rating) }}

    + @if ($review->title)

    {{ $review->title }}

    @endif + @if ($review->body)
    „{{ $review->body }}“
    @endif +
    {{ $review->display_name }}@if ($review->stayed_on) · {{ $review->stayed_on->translatedFormat('F Y') }}@endif
    + @if ($review->response) +

    Antwort der Gastgeber: {{ $review->response }}

    + @endif +
    +
  • + @endforeach +
+

Bewertungen über unsere Webseite können nur Gäste mit einer Buchung bei uns abgeben. Übernommene Bewertungen anderer Portale sind mit ihrer Quelle gekennzeichnet.

+
+@endif diff --git a/resources/themes/ostsee-licht/views/sections/rich_text.blade.php b/resources/themes/ostsee-licht/views/sections/rich_text.blade.php new file mode 100644 index 0000000..7475231 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/rich_text.blade.php @@ -0,0 +1,8 @@ +
+ @if ($heading)

{{ $heading }}

@endif + @if ($text) +
{{ $text }}
+ @else +

Dieser Text wird gerade überarbeitet.

+ @endif +
diff --git a/resources/themes/ostsee-licht/views/sections/text_image.blade.php b/resources/themes/ostsee-licht/views/sections/text_image.blade.php new file mode 100644 index 0000000..da3a360 --- /dev/null +++ b/resources/themes/ostsee-licht/views/sections/text_image.blade.php @@ -0,0 +1,21 @@ +
+
$imagePosition === 'left'])> + @if ($eyebrow)

{{ $eyebrow }}

@endif +

{{ $heading }}

+ @if ($text)
{{ $text }}
@endif + @if ($linkLabel && $linkUrl) + {{ $linkLabel }} + @endif +
+ @if ($photos->isNotEmpty()) +
$imagePosition === 'left'])> + @foreach ($photos as $index => $photo) + @include('theme::partials.image', [ + 'photo' => $photo, + 'sizes' => $index === 0 ? '(min-width: 1024px) 40vw, 100vw' : '(min-width: 1024px) 20vw, 50vw', + 'class' => $index === 0 && $photos->count() > 1 ? 'col-span-2 h-72 w-full rounded-sm object-cover sm:h-[26rem]' : ($photos->count() === 1 ? 'col-span-2 h-80 w-full rounded-sm object-cover sm:h-[28rem]' : 'h-44 w-full rounded-sm object-cover sm:h-56'), + ]) + @endforeach +
+ @endif +
diff --git a/resources/views/booking.blade.php b/resources/views/booking.blade.php deleted file mode 100644 index 44a6741..0000000 --- a/resources/views/booking.blade.php +++ /dev/null @@ -1,11 +0,0 @@ - -

Preise & Buchung

-

- Wählen Sie im Kalender Ihren Anreise- und Abreisetag. Sie sehen sofort den Gesamtpreis inklusive aller Nebenkosten. - Ihre Anfrage ist unverbindlich – wir halten den Termin für Sie vor und bestätigen kurzfristig. -

- -
- -
-
diff --git a/resources/views/components/layouts/site.blade.php b/resources/views/components/layouts/site.blade.php deleted file mode 100644 index 65c06b9..0000000 --- a/resources/views/components/layouts/site.blade.php +++ /dev/null @@ -1,39 +0,0 @@ -@props(['title' => null, 'description' => null]) - - - - - - {{ $title ? $title.' · ' : '' }}Ferienwohnung Stommer in Kühlungsborn - @if ($description) - - @endif - @vite(['resources/css/app.css', 'resources/js/app.js']) - @livewireStyles - - - Zum Inhalt springen - -
- -
- -
- {{ $slot }} -
- - - - @livewireScripts - - diff --git a/resources/views/livewire/booking-request.blade.php b/resources/views/livewire/booking-request.blade.php index e4bcddb..386f1c6 100644 --- a/resources/views/livewire/booking-request.blade.php +++ b/resources/views/livewire/booking-request.blade.php @@ -1,6 +1,6 @@
@if ($booking) -
+

Vielen Dank, {{ $booking->guest->first_name }}!

Ihre Anfrage {{ $booking->reference }} ist eingegangen. Wir haben den Zeitraum @@ -13,22 +13,22 @@

{{-- Calendar --}}
-
+
-

Belegung

+

Belegung

- - + +
@foreach ($this->calendar as $month)
-

{{ $month['label'] }}

+

{{ $month['label'] }}

- + @foreach (['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'] as $weekday) @endforeach @@ -47,11 +47,11 @@ aria-label="{{ \Carbon\CarbonImmutable::parse($day['date'])->translatedFormat('l, d. F Y') }}{{ $day['free'] ? '' : ' (Nacht belegt)' }}" @class([ 'aspect-square w-full rounded-lg text-sm transition', - 'cursor-not-allowed text-slate-300' => $day['past'], - 'bg-sea-700 font-semibold text-white' => $day['selected'], - 'bg-sea-100 text-sea-900' => $day['inRange'] && ! $day['selected'], + 'cursor-not-allowed text-muted/40' => $day['past'], + 'bg-accent font-semibold text-accent-ink' => $day['selected'], + 'bg-accent/15 text-ink' => $day['inRange'] && ! $day['selected'], 'bg-rose-100 text-rose-800 line-through decoration-rose-300' => ! $day['free'] && ! $day['past'] && ! $day['selected'], - 'hover:bg-sea-50' => $day['free'] && ! $day['past'] && ! $day['selected'] && ! $day['inRange'], + 'hover:bg-accent/10' => $day['free'] && ! $day['past'] && ! $day['selected'] && ! $day['inRange'], ])> {{ $day['day'] }} @@ -66,25 +66,25 @@ @endforeach -
- frei +
+ frei Nacht belegt (Abreise möglich) - Ihre Auswahl + Ihre Auswahl
diff --git a/resources/views/livewire/review-form.blade.php b/resources/views/livewire/review-form.blade.php index 1c9788d..cedfa96 100644 --- a/resources/views/livewire/review-form.blade.php +++ b/resources/views/livewire/review-form.blade.php @@ -1,26 +1,26 @@
@if ($submitted) -
+

Herzlichen Dank!

Ihre Bewertung ist bei uns angekommen. Wir freuen uns über jede Rückmeldung.

@elseif (! $canReview) -
-

Für diesen Aufenthalt wurde bereits eine Bewertung abgegeben. Vielen Dank!

+
+

Für diesen Aufenthalt wurde bereits eine Bewertung abgegeben. Vielen Dank!

@else -
+
-

Ihr Aufenthalt vom {{ $booking->arrival->format('d.m.') }} bis {{ $booking->departure->format('d.m.Y') }}

-

Bewertungen können nur von Gästen mit einer Buchung abgegeben werden.

+

Ihr Aufenthalt vom {{ $booking->arrival->format('d.m.') }} bis {{ $booking->departure->format('d.m.Y') }}

+

Bewertungen können nur von Gästen mit einer Buchung abgegeben werden.

- Wie hat es Ihnen insgesamt gefallen? + Wie hat es Ihnen insgesamt gefallen?
@for ($star = 1; $star <= 5; $star++) + @class(['text-4xl leading-none transition', 'text-accent' => $star <= $rating, 'text-line hover:text-accent/60' => $star > $rating])>★ @endfor
@error('rating')

{{ $message }}

@enderror @@ -29,11 +29,11 @@
@foreach ($categoryLabels as $field => $label)
- {{ $label }} + {{ $label }}
@for ($star = 1; $star <= 5; $star++) + @class(['text-2xl leading-none', 'text-accent' => $star <= $categories[$field], 'text-line hover:text-accent/60' => $star > $categories[$field]])>★ @endfor
@@ -41,23 +41,23 @@
@@ -66,7 +66,7 @@ Meine Bewertung darf mit dem angegebenen Namen auf der Webseite veröffentlicht werden. - diff --git a/resources/views/marketing-consent.blade.php b/resources/views/marketing-consent.blade.php index 0b29764..fe7edb4 100644 --- a/resources/views/marketing-consent.blade.php +++ b/resources/views/marketing-consent.blade.php @@ -1,9 +1,13 @@ - -
-

{{ $title }}

-

{{ $message }}

- @if ($unsubscribeUrl) -

Doch nicht? Hier abmelden.

- @endif +@extends('theme::layouts.app', ['title' => $title]) + +@section('content') +
+
+

{{ $title }}

+

{{ $message }}

+ @if ($unsubscribeUrl) +

Doch nicht? Hier abmelden.

+ @endif +
- +@endsection diff --git a/resources/views/review.blade.php b/resources/views/review.blade.php index 7d9c303..7364188 100644 --- a/resources/views/review.blade.php +++ b/resources/views/review.blade.php @@ -1,8 +1,12 @@ - -

Wie war Ihr Aufenthalt?

-

Vielen Dank, dass Sie sich einen Moment Zeit nehmen.

+@extends('theme::layouts.app', ['title' => 'Ihre Bewertung']) -
- +@section('content') +
+

Wie war Ihr Aufenthalt?

+

Vielen Dank, dass Sie sich einen Moment Zeit nehmen.

+ +
+ +
- +@endsection diff --git a/resources/views/sitemap.blade.php b/resources/views/sitemap.blade.php new file mode 100644 index 0000000..fc6898f --- /dev/null +++ b/resources/views/sitemap.blade.php @@ -0,0 +1,9 @@ +{!! '<'.'?xml version="1.0" encoding="UTF-8"?>' !!} + +@foreach ($pages as $page) + + {{ $page->url() }} + {{ $page->updated_at?->toAtomString() }} + +@endforeach + diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php deleted file mode 100644 index 22d6130..0000000 --- a/resources/views/welcome.blade.php +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - {{ config('app.name', 'Laravel') }} - - - - @if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot'))) - @vite(['resources/css/app.css', 'resources/js/app.js']) - @else - - @endif - - -
- @if (Route::has('login')) - - @endif -
-
-
-
-

Let's get started

-

With so many options available to you,
we suggest you start with the following:

- - - -

- v{{ app()->version() }} - - View changelog - - - - -

-
-
- {{-- Laravel Logo --}} - - - - - - - - - - - {{-- 13 --}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
- - @if (Route::has('login')) - - @endif - - diff --git a/routes/web.php b/routes/web.php index 2379fbf..4d8326e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,16 +2,11 @@ use App\Http\Controllers\ChannelController; use App\Http\Controllers\MarketingConsentController; +use App\Http\Controllers\PageController; use App\Models\Booking; use Illuminate\Foundation\Http\Middleware\PreventRequestForgery; use Illuminate\Support\Facades\Route; -Route::get('/', function () { - return view('welcome'); -}); - -Route::view('/buchen', 'booking')->name('booking.create'); - Route::middleware('signed')->group(function () { Route::get('/bewertung/{booking}', fn (Booking $booking) => view('review', ['booking' => $booking]))->name('reviews.create'); Route::get('/angebote/bestaetigen/{guest}', [MarketingConsentController::class, 'confirm'])->name('marketing.confirm'); @@ -28,3 +23,13 @@ ->name('channel-tasks.complete') ->withoutMiddleware(PreventRequestForgery::class) ->middleware('throttle:30,1'); + +Route::get('/sitemap.xml', [PageController::class, 'sitemap'])->name('sitemap'); +Route::get('/robots.txt', [PageController::class, 'robots'])->name('robots'); + +// Website pages (theme system). The booking page keeps its own name because e-mails link to it. +Route::get('/', [PageController::class, 'home'])->name('home'); +Route::get('/buchen', [PageController::class, 'show'])->defaults('slug', 'buchen')->name('booking.create'); +Route::get('/{slug}', [PageController::class, 'show']) + ->where('slug', '(?!admin|livewire|storage|up$)[a-z0-9-]+') + ->name('page'); diff --git a/tests/Feature/BookingRequestPageTest.php b/tests/Feature/BookingRequestPageTest.php index 2efe461..884850d 100644 --- a/tests/Feature/BookingRequestPageTest.php +++ b/tests/Feature/BookingRequestPageTest.php @@ -8,6 +8,7 @@ use App\Models\Property; use Carbon\CarbonImmutable; use Database\Seeders\PropertySeeder; +use Database\Seeders\SiteSeeder; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Mail; use Livewire\Livewire; @@ -22,7 +23,7 @@ protected function setUp(): void parent::setUp(); $this->travelTo(CarbonImmutable::parse('2026-10-22 10:00')); - $this->seed(PropertySeeder::class); + $this->seed([PropertySeeder::class, SiteSeeder::class]); Mail::fake(); } diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index 8364a84..0000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,19 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Feature/ThemeSystemTest.php b/tests/Feature/ThemeSystemTest.php new file mode 100644 index 0000000..7407fca --- /dev/null +++ b/tests/Feature/ThemeSystemTest.php @@ -0,0 +1,223 @@ +travelTo(CarbonImmutable::parse('2026-10-22 10:00')); + $this->seed([PropertySeeder::class, WebsiteContentSeeder::class, SiteSeeder::class]); + $this->site = Site::sole(); + $this->withoutVite(); + } + + public function test_base_theme_is_discovered_and_provides_a_view_for_every_section(): void + { + $theme = app(ThemeRegistry::class)->get('ostsee-licht'); + $this->assertSame('Ostsee-Licht', $theme->name); + $this->assertArrayHasKey('accent', $theme->tokens); + + foreach (array_keys(app(SectionRegistry::class)->all()) as $section) { + $this->assertFileExists($theme->viewsPath()."/sections/{$section}.blade.php", "Section {$section} needs a view in the base theme"); + } + } + + /** + * @return array + */ + public static function pageProvider(): array + { + return array_map(fn (string $slug): array => [$slug], array_combine( + ['Start', 'Wohnung', 'Kühlungsborn', 'Buchen', 'Kontakt', 'Impressum', 'Datenschutz'], + ['/', '/wohnung', '/kuehlungsborn', '/buchen', '/kontakt', '/impressum', '/datenschutz'], + )); + } + + #[DataProvider('pageProvider')] + public function test_every_seeded_page_renders(string $path): void + { + $this->get($path)->assertOk()->assertSee('Zum Inhalt springen')->assertSee('Preise & Buchung', false); + } + + public function test_home_page_shows_content_from_the_admin(): void + { + $photo = Photo::factory()->create(['alt_text' => 'Terrasse im Sommer']); + Review::factory()->for(Property::sole())->create(['status' => ReviewStatus::Approved, 'display_name' => 'Familie M.', 'body' => 'Wunderbar ruhig!']); + + $this->get('/') + ->assertOk() + ->assertSee('Ihr Zuhause zwischen Garten und Meer', false) + ->assertSee('53 m²') + ->assertSee('Wunderbar ruhig!') + ->assertSee('"@type":"VacationRental"', false) + ->assertSee('--accent:#2C5F7C', false); + $this->assertNotNull($photo); + } + + public function test_unknown_and_unpublished_pages_are_not_found(): void + { + Page::factory()->for($this->site)->create(['slug' => 'entwurf', 'is_published' => false]); + + $this->get('/gibt-es-nicht')->assertNotFound(); + $this->get('/entwurf')->assertNotFound(); + } + + /** + * @return array + */ + public static function seasonProvider(): array + { + return [ + 'Herbst → Standard' => ['2026-10-22', 'Standard'], + 'Sommer' => ['2026-07-15', 'Sommer'], + 'Winter (über den Jahreswechsel)' => ['2027-02-10', 'Winter'], + 'Weihnachten schlägt Winter' => ['2026-12-20', 'Weihnachten'], + 'Silvester schlägt Winter, vor Neujahr' => ['2026-12-31', 'Silvester'], + 'Silvester, nach Neujahr' => ['2027-01-02', 'Silvester'], + ]; + } + + #[DataProvider('seasonProvider')] + public function test_appearance_follows_the_calendar_and_priority(string $date, string $expected): void + { + $this->assertSame($expected, $this->site->appearanceOn(CarbonImmutable::parse($date))?->name); + } + + public function test_seasonal_appearance_changes_texts_colours_and_banner(): void + { + $this->travelTo(CarbonImmutable::parse('2026-12-20 10:00')); + + $this->get('/') + ->assertOk() + ->assertSee('data-appearance="weihnachten"', false) + ->assertSee('Besinnliche Tage am Meer', false) + ->assertSee('Weihnachten an der Ostsee: 19.–26.12.') + ->assertSee('--accent:#8C2F39', false); + } + + public function test_signed_preview_shows_another_appearance_and_is_not_indexed(): void + { + $silvester = $this->site->appearances()->where('name', 'Silvester')->sole(); + + $this->get(URL::temporarySignedRoute('home', now()->addHour(), ['vorschau' => $silvester->id])) + ->assertOk() + ->assertSee('Ins neue Jahr mit Meerblick', false) + ->assertSee('', false); + + $this->get('/?vorschau='.$silvester->id)->assertOk()->assertDontSee('Ins neue Jahr'); + } + + public function test_child_theme_overrides_only_what_it_provides(): void + { + $path = storage_path('framework/testing/themes'); + @mkdir($path.'/kind/views/sections', 0777, true); + file_put_contents($path.'/kind/theme.json', json_encode(['key' => 'kind', 'name' => 'Kind', 'parent' => 'ostsee-licht', 'tokens' => ['accent' => ['label' => 'Akzent', 'default' => '#FF0000']]])); + file_put_contents($path.'/kind/views/sections/facts.blade.php', '

Eckdaten im Kind-Theme

'); + config(['themes.paths' => [resource_path('themes'), $path]]); + app()->forgetInstance(ThemeRegistry::class); + + $this->site->update(['theme' => 'kind']); + $theme = app(ThemeFactory::class)->forSite($this->site->fresh())->activate(); + app()->instance(Theme::class, $theme); + + $this->assertSame(['kind', 'ostsee-licht'], array_map(fn ($manifest) => $manifest->key, $theme->chain())); + $this->assertSame('#FF0000', $theme->tokens()['accent']); + $this->assertSame('#F6F2EA', $theme->tokens()['ground']); + $this->assertStringContainsString('Eckdaten im Kind-Theme', view('theme::sections.facts')->render()); + $this->assertTrue(view()->exists('theme::sections.hero'), 'falls back to the base theme'); + } + + public function test_sitemap_and_robots(): void + { + $this->get('/sitemap.xml')->assertOk()->assertHeader('Content-Type', 'application/xml')->assertSee(url('/wohnung'), false); + $this->get('/robots.txt')->assertOk()->assertSee('Disallow: /admin')->assertSee('Sitemap: '.url('/sitemap.xml')); + } + + public function test_availability_search_prefills_the_booking_page(): void + { + $this->get('/buchen?anreise=2026-11-07&abreise=2026-11-10&personen=3') + ->assertOk() + ->assertSee('Gesamtpreis'); + } + + public function test_content_editor_manages_pages_and_appearances(): void + { + $this->actingAs(User::factory()->role(UserRole::Content)->create()); + + $this->get(PageResource::getUrl('index'))->assertOk()->assertSee('Die Wohnung'); + $this->get(AppearanceResource::getUrl('index'))->assertOk()->assertSee('Weihnachten'); + $this->get(SiteResource::getUrl('index'))->assertForbidden(); + + $page = $this->site->pages()->where('slug', 'kontakt')->sole(); + $this->get(PageResource::getUrl('edit', ['record' => $page]))->assertOk(); + + Livewire::test(EditPage::class, ['record' => $page->getRouteKey()]) + ->set('data.title', 'Kontakt & Anfahrt') + ->call('save') + ->assertHasNoFormErrors(); + $this->assertSame('Kontakt & Anfahrt', $page->fresh()->title); + + Livewire::test(CreateAppearance::class) + ->fillForm([ + 'name' => 'Ostern', + 'site_id' => $this->site->id, + 'starts_md' => '28.3.', + 'ends_md' => '12.04.', + 'priority' => 15, + 'is_active' => true, + 'overrides' => ['hero' => ['title' => 'Frühling an der Ostsee']], + 'tokens' => ['accent' => '#5A7D3A'], + ]) + ->call('create') + ->assertHasNoFormErrors(); + + $easter = Appearance::where('name', 'Ostern')->sole(); + $this->assertSame(['03-28', '04-12', 'Frühling an der Ostsee', '#5A7D3A'], [$easter->starts_md, $easter->ends_md, $easter->override('hero.title'), $easter->tokens['accent']]); + $this->assertSame('Ostern', $this->site->appearanceOn(CarbonImmutable::parse('2027-04-01'))->name); + } + + public function test_invalid_day_is_rejected(): void + { + $this->actingAs(User::factory()->create()); + + Livewire::test(CreateAppearance::class) + ->fillForm(['name' => 'Kaputt', 'site_id' => $this->site->id, 'starts_md' => '31.02.', 'ends_md' => '01.03.']) + ->call('create') + ->assertHasFormErrors(['starts_md']); + } +} diff --git a/tests/Feature/WebsiteContentTest.php b/tests/Feature/WebsiteContentTest.php index 665ba2b..7843661 100644 --- a/tests/Feature/WebsiteContentTest.php +++ b/tests/Feature/WebsiteContentTest.php @@ -49,15 +49,15 @@ public function test_content_editor_sees_website_areas_but_not_bookings(): void public function test_texts_fall_back_to_defaults_and_can_be_saved(): void { - $this->assertSame('Ihr Zuhause zwischen Garten und Meer', Content::get('home.hero.title')); + $this->assertStringContainsString('seit über 20 Jahren', Content::get('host.quote')); Livewire::test(EditContent::class) - ->set('data.home__hero__title', 'Willkommen an der Ostsee') + ->set('data.host__quote', 'Willkommen an der Ostsee') ->set('data.legal__imprint', '

Angaben gemäß § 5 DDG

') ->call('save') ->assertNotified('Texte gespeichert'); - $this->assertSame('Willkommen an der Ostsee', Content::get('home.hero.title')); + $this->assertSame('Willkommen an der Ostsee', Content::get('host.quote')); $this->assertStringContainsString('§ 5 DDG', (string) Content::html('legal.imprint')); $this->assertStringNotContainsString('
{{ $weekday }}