*/ public array $content = []; /** @var array */ public array $slides = []; public function mount(): void { $section = cms_theme_section('hero_slider'); $this->content = is_array($section) ? $section : []; $this->slides = $this->slidesFromContent() ?: $this->slidesFromBrands(); } /** * @return array */ private function slidesFromContent(): array { $slides = []; foreach ((array) ($this->content['slides'] ?? []) 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'] ?? '')); $slides[] = [ 'image' => (string) $slide['image'], 'alt' => trim((string) ($slide['alt'] ?? $label)), 'label' => $label, 'caption' => trim((string) ($slide['caption'] ?? '')), ]; } return $slides; } /** * @return array */ private function slidesFromBrands(): array { $slides = []; foreach (CmsBrand::forFrontend() as $brand) { $image = trim((string) ($brand['image'] ?? '')); if ($image === '') { continue; } $name = (string) ($brand['name'] ?? ''); $slides[] = [ 'image' => $image, 'alt' => $name.' – '.strip_tags((string) ($brand['tagline'] ?? '')), 'label' => $name, 'caption' => strip_tags((string) ($brand['tagline'] ?? '')), ]; } return $slides; } 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-slider'); } }