*/ public array $content = []; /** @var array */ public array $slides = []; public function mount(): void { $section = cms_theme_section('hero'); $this->content = is_array($section) ? $section : []; $this->slides = self::activeSlides($this->content['slides'] ?? []) ?: $this->singleImage(); } /** * Gepflegte Slides ohne Bild oder mit `active` = aus fallen weg. * * @return array */ public static function activeSlides(mixed $list): array { $slides = []; foreach ((array) $list as $slide) { if (! is_array($slide) || trim((string) ($slide['image'] ?? '')) === '') { continue; } if (array_key_exists('active', $slide) && ! filter_var($slide['active'], FILTER_VALIDATE_BOOLEAN)) { continue; } $label = trim((string) ($slide['label'] ?? $slide['title'] ?? '')); $caption = trim((string) ($slide['caption'] ?? '')); $slides[] = [ 'image' => (string) $slide['image'], 'alt' => trim((string) ($slide['alt'] ?? '')) ?: implode(' – ', array_filter([$label, $caption])), 'label' => $label, 'caption' => $caption, ]; } return $slides; } /** * @return array */ private function singleImage(): array { $image = trim((string) ($this->content['image'] ?? '')); return $image === '' ? [] : [[ 'image' => $image, 'alt' => (string) ($this->content['image_alt'] ?? ''), 'label' => '', 'caption' => '', ]]; } /** Wechsel alle `interval` Sekunden, begrenzt auf 3–30 s (Standard 7 s). */ public function getIntervalMsProperty(): int { $seconds = (float) ($this->content['interval'] ?? 7); return (int) round(max(3, min(30, $seconds)) * 1000); } public function render(): \Illuminate\View\View { return view('livewire.web.components.sections.hero'); } }