url = $url; $this->fetchOptions(); } public function fetchOptions() { try { $response = Http::get($this->url); $this->options = $response->json('data') ?? [ ['value' => 'zhejiang', 'label' => 'Zhejiang', 'children' => [ ['value' => 'hangzhou', 'label' => 'Hangzhou', 'children' => [ ['value' => 'xihu', 'label' => 'West Lake'] ]] ]], ['value' => 'jiangsu', 'label' => 'Jiangsu', 'children' => [ ['value' => 'nanjing', 'label' => 'Nanjing', 'children' => [ ['value' => 'zhonghuamen', 'label' => 'Zhong Hua Men'] ]] ]] ]; } catch (\Exception $e) { session()->flash('error', 'Failed to load options: ' . $e->getMessage()); } } public function updatedSelected() { $this->dispatch('cascaderChanged', $this->selected); } public function render() { return view('livewire.cascader-form'); } }