fetchFuels(); } public function fetchFuels() { try { $response = Http::get('https://api.example.com/fuels'); if ($response->successful()) { $this->fuels = $response->json()['data'] ?? []; } else { $this->alert('error', 'Failed to fetch fuels.'); } } 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 fuel?')) { try { $this->updating = true; $response = Http::delete("https://api.example.com/fuels/{$id}"); if ($response->successful()) { $this->alert('success', 'Fuel deleted successfully!'); $this->fetchFuels(); } else { $this->alert('error', 'Failed to delete fuel.'); } } catch (\Exception $e) { $this->alert('error', 'An error occurred: ' . $e->getMessage()); } finally { $this->updating = false; } } } public function render() { return view('livewire.station-locator.fuel-list')->layout('layouts.app', ['title' => 'Fuel List']); } }