fetchData(); } public function fetchData() { try { $this->updating = true; $response = Http::get('https://api.example.com/reportTopUp'); if ($response->successful()) { $this->data = $response->json()['data'] ?? []; } else { $this->alert('error', 'Failed to fetch top-up report data.'); } } catch (\Exception $e) { $this->alert('error', 'An error occurred: ' . $e->getMessage()); } finally { $this->updating = false; } } public function render() { return view('livewire.reports.top-up-list')->layout('layouts.app', ['title' => 'Top-Up Usage Report']); } // In TopUpList.php public function exportCsv() { $response = Http::get('https://api.example.com/reportTopUpExport'); if ($response->successful()) { return response($response->body()) ->header('Content-Type', 'text/csv') ->header('Content-Disposition', 'attachment; filename="TopUpUsageReport.csv"'); } $this->alert('error', 'Failed to export CSV.'); } }