B2in Interior: Relaunch der Website, Kernmarken-CMS und Terminanfrage
Umsetzung von AP0-AP6 aus dev/2026-08-28/entwicklungsplan.md sowie der vorab gefundenen Befunde T1 und B1-B13. Befunde - CmsContentSeeder überschrieb bei jedem Lauf alle redaktionellen Inhalte; jetzt Redaktionsschutz plus gezielter Relaunch-Seeder (B1) - Magazin-CMS war nicht ans Frontend angebunden, Artikel jetzt über Slugs mit 301 von den alten numerischen URLs (B2) - Vier veröffentlichte Display-Playlists zeigten auf b2in.test und wären live nicht ladbar gewesen (B13) - Info-Tablet speicherte geleerte Öffnungszeiten nicht (T1) - /service und /portfolio lieferten seit Februar 500 (B12) Website - Startseite neu strukturiert und umgetextet, eigene Seite /marken mit Detailseite je Kernmarke, /netzwerk und Altrouten leiten dorthin - Galerie je Marke, getrennt nach realisierten Projekten und Visualisierungen; ohne gesetzte Kategorie gilt ein Bild als Entwurf - Seite /referenzen, gespeist aus den Markengalerien - Showroom-Display im 9:16-Rahmen über eine schreibgeschützte Embed-Route ohne Preview-Token - Terminanfrage-Widget auf allen Seiten, Markenauswahl aus dem CMS, WhatsApp per Klick-zum-Chat-Link mit vorbereitetem Text - FAQ, Über-uns, Kontakt und Magazin inhaltlich auf Interior umgestellt Sonstiges - Vorschau-Instanzen liefern noindex und verlinken sich bei unbekanntem Host auf sich selbst statt auf eine fremde Domain - Seeder-Zugangsdaten aus dem Code in die Konfiguration (B8) - Ablauf für die Vorschau: dev/2026-08-28/preview-deployment.md 833 Tests grün (3084 Assertions), Pint sauber. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
193d37b1ce
commit
6d53243ea6
132 changed files with 8672 additions and 335 deletions
25
app/Livewire/Web/Components/Sections/AudienceSwitch.php
Normal file
25
app/Livewire/Web/Components/Sections/AudienceSwitch.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class AudienceSwitch extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public function mount(string $bg = ''): void
|
||||
{
|
||||
$section = cms_theme_section('audience_switch');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.audience-switch');
|
||||
}
|
||||
}
|
||||
44
app/Livewire/Web/Components/Sections/BrandDetail.php
Normal file
44
app/Livewire/Web/Components/Sections/BrandDetail.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use App\Models\CmsBrand;
|
||||
use Livewire\Component;
|
||||
|
||||
class BrandDetail extends Component
|
||||
{
|
||||
public string $slug = '';
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
public array $brand = [];
|
||||
|
||||
/** @var array<int, array<string, mixed>> */
|
||||
public array $otherBrands = [];
|
||||
|
||||
/**
|
||||
* Galerie getrennt nach realisierten Projekten und Inspirationen.
|
||||
*
|
||||
* @var array{projects: array<int, array<string, mixed>>, inspirations: array<int, array<string, mixed>>}
|
||||
*/
|
||||
public array $gallery = ['projects' => [], 'inspirations' => []];
|
||||
|
||||
public function mount(string $slug): void
|
||||
{
|
||||
$brands = CmsBrand::forFrontend();
|
||||
|
||||
abort_unless(isset($brands[$slug]), 404);
|
||||
|
||||
$this->slug = $slug;
|
||||
$this->brand = $brands[$slug];
|
||||
$this->gallery = CmsBrand::groupGallery($this->brand['gallery'] ?? []);
|
||||
$this->otherBrands = collect($brands)
|
||||
->reject(fn (array $brand, string $key) => $key === $slug)
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.brand-detail');
|
||||
}
|
||||
}
|
||||
25
app/Livewire/Web/Components/Sections/BrandOverview.php
Normal file
25
app/Livewire/Web/Components/Sections/BrandOverview.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use App\Models\CmsBrand;
|
||||
use Livewire\Component;
|
||||
|
||||
class BrandOverview extends Component
|
||||
{
|
||||
/** @var array<int, array<string, mixed>> */
|
||||
public array $brands = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public function mount(string $bg = ''): void
|
||||
{
|
||||
$this->brands = array_values(CmsBrand::forFrontend());
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.brand-overview');
|
||||
}
|
||||
}
|
||||
30
app/Livewire/Web/Components/Sections/CoreBrands.php
Normal file
30
app/Livewire/Web/Components/Sections/CoreBrands.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use App\Models\CmsBrand;
|
||||
use Livewire\Component;
|
||||
|
||||
class CoreBrands extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
/** @var array<int, array<string, mixed>> */
|
||||
public array $brands = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public function mount(string $bg = ''): void
|
||||
{
|
||||
$section = cms_theme_section('core_brands');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->brands = array_values(CmsBrand::forFrontend());
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.core-brands');
|
||||
}
|
||||
}
|
||||
72
app/Livewire/Web/Components/Sections/DisplayFeed.php
Normal file
72
app/Livewire/Web/Components/Sections/DisplayFeed.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use App\Models\Display;
|
||||
use App\Models\DisplayPlaylist;
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* Spiegelt ein Showroom-Display im Hochformat (9:16) auf der Website.
|
||||
*
|
||||
* Quelle ist dasselbe veröffentlichte Playlist wie beim physischen Display – Marcel pflegt
|
||||
* weiterhin nur im Display-CMS, hier entsteht keine zweite Pflegestelle.
|
||||
*/
|
||||
class DisplayFeed extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public ?int $displayId = null;
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public bool $showLink = true;
|
||||
|
||||
public function mount(string $bg = '', bool $showLink = true): void
|
||||
{
|
||||
$section = cms_theme_section('display_feed');
|
||||
$content = is_array($section) ? $section : [];
|
||||
|
||||
$this->bg = $bg;
|
||||
$this->showLink = $showLink;
|
||||
$this->displayId = $this->resolveDisplayId($content);
|
||||
|
||||
// Ohne Display bleiben auch die Texte leer – sie hätten sonst nichts zu beschriften und
|
||||
// stünden trotzdem im Livewire-Snapshot der Seite.
|
||||
$this->content = $this->displayId === null ? [] : $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Im CMS hinterlegtes Display, sonst das erste aktive mit veröffentlichter Playlist.
|
||||
*
|
||||
* Ohne passendes Display rendert die Sektion nichts – lieber keine Sektion als ein
|
||||
* Rahmen, in dem sich ewig ein Ladebalken dreht.
|
||||
*
|
||||
* @param array<string, mixed> $content
|
||||
*/
|
||||
private function resolveDisplayId(array $content): ?int
|
||||
{
|
||||
$configured = $content['display_id'] ?? null;
|
||||
|
||||
$query = Display::query()
|
||||
->where('is_active', true)
|
||||
->whereHas('playlists', fn ($q) => $q->where('status', DisplayPlaylist::STATUS_PUBLISHED)
|
||||
->whereHas('modules'));
|
||||
|
||||
if (is_numeric($configured) && (int) $configured > 0) {
|
||||
$display = (clone $query)->whereKey((int) $configured)->first();
|
||||
|
||||
if ($display !== null) {
|
||||
return $display->id;
|
||||
}
|
||||
}
|
||||
|
||||
return $query->orderBy('id')->value('id');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.display-feed');
|
||||
}
|
||||
}
|
||||
25
app/Livewire/Web/Components/Sections/ImmobilienTeaser.php
Normal file
25
app/Livewire/Web/Components/Sections/ImmobilienTeaser.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class ImmobilienTeaser extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public function mount(string $bg = ''): void
|
||||
{
|
||||
$section = cms_theme_section('immobilien_teaser');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.immobilien-teaser');
|
||||
}
|
||||
}
|
||||
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use App\Models\CmsArticle;
|
||||
use Livewire\Component;
|
||||
|
||||
class MagazinDetail extends Component
|
||||
{
|
||||
public $articleId;
|
||||
public $slug;
|
||||
|
||||
public $article;
|
||||
|
||||
|
|
@ -14,9 +15,9 @@ class MagazinDetail extends Component
|
|||
|
||||
public $content;
|
||||
|
||||
public function mount($id = 1)
|
||||
public function mount($slug)
|
||||
{
|
||||
$this->articleId = (int) $id;
|
||||
$this->slug = (string) $slug;
|
||||
$this->loadArticle();
|
||||
$this->loadRelatedArticles();
|
||||
$this->loadThemeContent();
|
||||
|
|
@ -25,14 +26,18 @@ class MagazinDetail extends Component
|
|||
private function loadArticle()
|
||||
{
|
||||
$articles = $this->getArticlesData();
|
||||
$this->article = $articles[$this->articleId] ?? $articles[1];
|
||||
|
||||
// Unbekannte Slugs haben frueher stillschweigend Artikel 1 ausgeliefert – mit Status 200.
|
||||
// Das erzeugt Duplicate Content unter beliebig vielen URLs.
|
||||
abort_unless(isset($articles[$this->slug]), 404);
|
||||
|
||||
$this->article = $articles[$this->slug];
|
||||
}
|
||||
|
||||
private function loadRelatedArticles()
|
||||
{
|
||||
$articles = $this->getArticlesData();
|
||||
$this->relatedArticles = collect($articles)
|
||||
->filter(fn ($article, $key) => $key != $this->articleId)
|
||||
$this->relatedArticles = collect($this->getArticlesData())
|
||||
->reject(fn (array $article, string $slug) => $slug === $this->slug)
|
||||
->take(2)
|
||||
->values()
|
||||
->toArray();
|
||||
|
|
@ -43,9 +48,18 @@ class MagazinDetail extends Component
|
|||
$this->content = cms_theme_section('magazin_detail');
|
||||
}
|
||||
|
||||
private function getArticlesData()
|
||||
/** @var array<string, array<string, mixed>>|null */
|
||||
private ?array $articlesCache = null;
|
||||
|
||||
/**
|
||||
* Wird beim Rendern zweimal gebraucht (Artikel + verwandte Artikel) – deshalb gemerkt,
|
||||
* damit die Detailseite nur eine Abfrage auslöst.
|
||||
*
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
private function getArticlesData(): array
|
||||
{
|
||||
return trans('b2in.articles');
|
||||
return $this->articlesCache ??= CmsArticle::forFrontend();
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use App\Models\CmsArticle;
|
||||
use Livewire\Component;
|
||||
|
||||
class MagazinList extends Component
|
||||
|
|
@ -18,17 +19,16 @@ class MagazinList extends Component
|
|||
|
||||
private function loadPosts()
|
||||
{
|
||||
$articles = trans('b2in.articles');
|
||||
$this->posts = collect($articles)->map(function ($article) {
|
||||
$this->posts = collect(CmsArticle::forFrontend())->map(function (array $article) {
|
||||
return [
|
||||
'id' => $article['id'],
|
||||
'slug' => $article['slug'],
|
||||
'title' => $article['title'],
|
||||
'excerpt' => $article['content']['intro'], // Using intro as excerpt
|
||||
'excerpt' => $article['content']['intro'] ?? '',
|
||||
'image' => $article['image'],
|
||||
'date' => $article['date'],
|
||||
'readTime' => $article['readTime'],
|
||||
];
|
||||
})->all();
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
private function loadThemeContent()
|
||||
|
|
@ -38,6 +38,8 @@ class MagazinList extends Component
|
|||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.magazin-list');
|
||||
return view('livewire.web.components.sections.magazin-list', [
|
||||
'posts' => $this->posts,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
25
app/Livewire/Web/Components/Sections/MarkenCta.php
Normal file
25
app/Livewire/Web/Components/Sections/MarkenCta.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class MarkenCta extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public function mount(string $bg = ''): void
|
||||
{
|
||||
$section = cms_theme_section('marken_cta');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.marken-cta');
|
||||
}
|
||||
}
|
||||
25
app/Livewire/Web/Components/Sections/MarkenGrowth.php
Normal file
25
app/Livewire/Web/Components/Sections/MarkenGrowth.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class MarkenGrowth extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public function mount(string $bg = ''): void
|
||||
{
|
||||
$section = cms_theme_section('marken_growth');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.marken-growth');
|
||||
}
|
||||
}
|
||||
25
app/Livewire/Web/Components/Sections/MarkenNetwork.php
Normal file
25
app/Livewire/Web/Components/Sections/MarkenNetwork.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class MarkenNetwork extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public function mount(string $bg = ''): void
|
||||
{
|
||||
$section = cms_theme_section('marken_network');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.marken-network');
|
||||
}
|
||||
}
|
||||
34
app/Livewire/Web/Components/Sections/PageHero.php
Normal file
34
app/Livewire/Web/Components/Sections/PageHero.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* Seitenkopf für Unterseiten: Breadcrumb, Überschrift, Text und optional ein Bild daneben.
|
||||
*
|
||||
* Liegt auf derselben abgesetzten grauen Fläche wie der Hero der Startseite, damit sich der
|
||||
* Kopf klar von den Inhaltsblöcken darunter abhebt.
|
||||
*/
|
||||
class PageHero extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public string $breadcrumb = '';
|
||||
|
||||
public function mount(string $section = 'marken_hero', string $breadcrumb = '', string $bg = ''): void
|
||||
{
|
||||
$content = cms_theme_section($section);
|
||||
$this->content = is_array($content) ? $content : [];
|
||||
$this->breadcrumb = $breadcrumb !== '' ? $breadcrumb : __('ui.brands');
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.page-hero');
|
||||
}
|
||||
}
|
||||
63
app/Livewire/Web/Components/Sections/ReferenceProjects.php
Normal file
63
app/Livewire/Web/Components/Sections/ReferenceProjects.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use App\Models\CmsBrand;
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* Realisierte Projekte aus den Markengalerien, über alle Marken hinweg gesammelt.
|
||||
*
|
||||
* Keine zweite Pflegestelle: Marcel pflegt die Bilder weiterhin je Marke im Kernmarken-Modul.
|
||||
* Hier erscheinen ausschließlich Einträge der Rubrik „Realisiertes Projekt" – Visualisierungen
|
||||
* und Entwürfe bleiben bewusst draußen, damit „Referenzen" hält, was das Wort verspricht.
|
||||
*/
|
||||
class ReferenceProjects extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
/** @var array<int, array<string, mixed>> */
|
||||
public array $projects = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public int $limit = 0;
|
||||
|
||||
public function mount(string $bg = '', int $limit = 0): void
|
||||
{
|
||||
$section = cms_theme_section('reference_projects');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->bg = $bg;
|
||||
$this->limit = $limit;
|
||||
$this->projects = $this->collectProjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private function collectProjects(): array
|
||||
{
|
||||
$projects = [];
|
||||
|
||||
foreach (CmsBrand::forFrontend() as $slug => $brand) {
|
||||
foreach (CmsBrand::groupGallery($brand['gallery'] ?? [])['projects'] as $index => $item) {
|
||||
$projects[] = [
|
||||
'key' => $slug.'-'.$index,
|
||||
'image' => $item['image'],
|
||||
'caption' => $item['caption'],
|
||||
'brand' => (string) ($brand['name'] ?? ''),
|
||||
'brand_slug' => $slug,
|
||||
'has_detail_page' => (bool) ($brand['has_detail_page'] ?? false),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->limit > 0 ? array_slice($projects, 0, $this->limit) : $projects;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.reference-projects');
|
||||
}
|
||||
}
|
||||
25
app/Livewire/Web/Components/Sections/Sponsoring.php
Normal file
25
app/Livewire/Web/Components/Sections/Sponsoring.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Sections;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Sponsoring extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public string $bg = '';
|
||||
|
||||
public function mount(string $bg = ''): void
|
||||
{
|
||||
$section = cms_theme_section('sponsoring');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->bg = $bg;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.sections.sponsoring');
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,25 @@ class AnnouncementBar extends Component
|
|||
$this->content = cms_theme_section('announcement_bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Schluessel, unter dem sich der Browser das Wegklicken merkt.
|
||||
*
|
||||
* Leitet sich aus dem Inhalt ab, nicht nur aus der gepflegten `id`: Wird die Leiste im CMS
|
||||
* neu belegt, ohne die `id` zu aendern, bekaemen Wiederkehrer die neue Meldung sonst nie
|
||||
* zu sehen, weil ihr alter Dismiss-Eintrag im localStorage weitergilt.
|
||||
*/
|
||||
public function getDismissKeyProperty(): string
|
||||
{
|
||||
$fingerprint = implode('|', [
|
||||
$this->content['id'] ?? 'default',
|
||||
$this->content['badge'] ?? '',
|
||||
$this->content['text'] ?? '',
|
||||
$this->content['link_url'] ?? '',
|
||||
]);
|
||||
|
||||
return 'announcement_dismissed_'.substr(md5($fingerprint), 0, 12);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.ui.announcement-bar');
|
||||
|
|
|
|||
129
app/Livewire/Web/Components/UI/AppointmentWidget.php
Normal file
129
app/Livewire/Web/Components/UI/AppointmentWidget.php
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Web\Components\Ui;
|
||||
|
||||
use Acme\ContactForm\ContactFormService;
|
||||
use Acme\ContactForm\SpamDetector;
|
||||
use App\Models\CmsBrand;
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* Schwebende Terminanfrage – auf allen Seiten unten rechts.
|
||||
*
|
||||
* Setzt wie die übrigen Formulare der Seite auf {@see ContactFormService} und {@see SpamDetector}
|
||||
* auf, statt auf Acme\ContactForm\Livewire\ContactForm: dessen mitgelieferte View bringt ein
|
||||
* eigenes (blaues) Layout mit, das nicht zum Auftritt passt. Honeypot, Rate-Limit und
|
||||
* Spam-Erkennung kommen so trotzdem aus dem Paket.
|
||||
*/
|
||||
class AppointmentWidget extends Component
|
||||
{
|
||||
/** Feste Anliegen neben den gepflegten Marken. */
|
||||
public const EXTRA_TOPICS = [
|
||||
'projektausstattung' => 'Projektausstattung',
|
||||
'sonstiges' => 'Sonstiges',
|
||||
];
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public string $email = '';
|
||||
|
||||
public string $phone = '';
|
||||
|
||||
public string $topic = '';
|
||||
|
||||
public string $preferredDate = '';
|
||||
|
||||
public string $message = '';
|
||||
|
||||
public bool $privacy = false;
|
||||
|
||||
public bool $success = false;
|
||||
|
||||
/** @var string Honeypot – muss leer bleiben. */
|
||||
public string $website = '';
|
||||
|
||||
public ?int $formLoadedAt = null;
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$section = cms_theme_section('appointment_widget');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
$this->formLoadedAt = time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Auswahl „Anliegen": gepflegte Kernmarken zuerst, danach die festen Einträge.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getTopicsProperty(): array
|
||||
{
|
||||
$brands = [];
|
||||
|
||||
foreach (CmsBrand::forFrontend() as $slug => $brand) {
|
||||
$brands[$slug] = (string) ($brand['name'] ?? $slug);
|
||||
}
|
||||
|
||||
return $brands + self::EXTRA_TOPICS;
|
||||
}
|
||||
|
||||
public function getWhatsappUrlProperty(): string
|
||||
{
|
||||
return whatsapp_link();
|
||||
}
|
||||
|
||||
public function submit(ContactFormService $service): void
|
||||
{
|
||||
$this->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email:rfc', 'max:255'],
|
||||
'phone' => ['nullable', 'string', 'max:80'],
|
||||
'topic' => ['nullable', 'string', 'max:255'],
|
||||
'preferredDate' => ['nullable', 'date', 'after_or_equal:today'],
|
||||
'message' => ['nullable', 'string', 'max:2000'],
|
||||
'privacy' => ['accepted'],
|
||||
'website' => ['nullable', 'string', 'max:0'],
|
||||
], [
|
||||
'preferredDate.after_or_equal' => __('ui.appointment.date_in_past'),
|
||||
]);
|
||||
|
||||
$topicLabel = $this->topics[$this->topic] ?? '';
|
||||
|
||||
$payload = [
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone' => $this->phone,
|
||||
'topic' => $topicLabel,
|
||||
'preferred_date' => $this->preferredDate,
|
||||
'message' => $this->message,
|
||||
'website' => $this->website,
|
||||
'source' => request()->path(),
|
||||
'ip' => request()->ip(),
|
||||
'user_agent' => request()->userAgent(),
|
||||
'is_spam' => false,
|
||||
];
|
||||
|
||||
$payload['is_spam'] = SpamDetector::fromConfig()->detect($payload, $this->formLoadedAt);
|
||||
|
||||
$subject = 'Terminanfrage B2in Interior'.($topicLabel !== '' ? ': '.$topicLabel : '');
|
||||
$service->handle($payload, $subject, 'appointment-widget');
|
||||
|
||||
$this->success = true;
|
||||
$this->reset(['name', 'email', 'phone', 'topic', 'preferredDate', 'message', 'privacy', 'website']);
|
||||
$this->formLoadedAt = time();
|
||||
}
|
||||
|
||||
public function startOver(): void
|
||||
{
|
||||
$this->success = false;
|
||||
$this->formLoadedAt = time();
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\View\View
|
||||
{
|
||||
return view('livewire.web.components.ui.appointment-widget');
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,15 @@ use Livewire\Component;
|
|||
|
||||
class Footer extends Component
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $content = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$section = cms_theme_section('footer');
|
||||
$this->content = is_array($section) ? $section : [];
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.web.components.ui.footer');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue