meta)) { $this->findStations(); } } public function updatedSort(): void { if (! empty($this->meta)) { $this->findStations(); } } public function updatedRadius(): void { if (! empty($this->meta)) { $this->findStations(); } } public function findStations(): void { $this->validate(); $this->results = []; $this->meta = []; $this->apiError = null; $radiusKm = round($this->radius * 1.60934, 2); try { $response = Http::timeout(10) ->withHeaders(['X-Api-Key' => config('app.api_secret_key')]) ->get(url('/api/stations'), [ 'postcode' => $this->search, 'fuel_type' => $this->fuelType, 'radius' => $radiusKm, 'sort' => $this->sort, ]); } catch (ConnectionException) { $this->apiError = 'Unable to fetch stations. Please try again.'; return; } if ($response->status() === 422) { $errors = $response->json('errors', []); $this->apiError = collect($errors)->flatten()->first() ?? $response->json('message', 'Validation error.'); return; } if (! $response->successful()) { $this->apiError = 'Unable to fetch stations. Please try again.'; return; } $this->results = $response->json('data', []); $this->meta = $response->json('meta', []); } public function render(): View { return view('livewire.public.station-search'); } }