fetchStations(); } public function fetchStations() { try { $response = Http::get('https://api.example.com/stations'); if ($response->successful()) { $this->stations = $response->json()['data'] ?? []; } else { $this->alert('error', 'Failed to fetch stations.'); } } catch (\Exception $e) { $this->alert('error', 'An error occurred: ' . $e->getMessage()); } } public function delete($id) { if (confirm('Are you sure you want to delete this station?')) { try { $response = Http::delete("https://api.example.com/stations/{$id}"); if ($response->successful()) { $this->alert('success', 'Station deleted successfully!'); $this->fetchStations(); } else { $this->alert('error', 'Failed to delete station.'); } } catch (\Exception $e) { $this->alert('error', 'An error occurred: ' . $e->getMessage()); } } } public function showLocation($station) { $this->dataLocation = $station; $this->locationModal = true; } public function toggleUploadPriceModal() { $this->uploadPriceModal = !$this->uploadPriceModal; } public function render() { return view('livewire.station-locator.station-list', [ 'stations' => $this->stations, ])->layout('layouts.app', ['title' => 'Station List']); } }