url = trim((string) $url); $this->title = $title ?: 'Video'; } public function provider(): ?string { if ($this->url === '') return null; $u = $this->url; if (stripos($u, 'url === '') return null; $u = $this->url; if (stripos($u, 'provider(); $id = $this->videoId(); if (!$provider || !$id) return null; return match ($provider) { 'youtube' => "https://www.youtube.com/embed/{$id}", 'vimeo' => "https://player.vimeo.com/video/{$id}?title=0&byline=0&portrait=0", default => null, }; } public function render(): View|Closure|string { return view('components.video-player', [ 'embedSrc' => $this->embedSrc(), 'provider' => $this->provider(), ]); } }