*/ 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->linkTargetVisible($content); $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 $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'); } /** * Der Button führt standardmäßig auf /referenzen – ist die Seite im CMS ausgeblendet, entfällt er. * * @param array $content */ private function linkTargetVisible(array $content): bool { $path = rtrim(parse_url((string) ($content['link_url'] ?? '/referenzen'), PHP_URL_PATH) ?? '', '/'); return $path !== '/referenzen' || references_page_enabled(); } }