loadMobileUsageReport(); // Load mobileUsageReport initially } public function loadMobileUsageReport() { try { $token = Session::get('user')['access_token'] ?? null; if (!$token) { $this->addError('users', 'No access token found.'); return; } $response = Http::withToken($token) ->get(config('services.backend_api.url') . '/api/cms/reportMobileUsage'); // dd($response->json()); if ($response->successful()) { // dd($response->json()['data']); // Properly use collect to handle the response data $this->mobileUsageReport = collect($response->json()['data']) ->map(function ($mobileUsageReport) { // dd($this->mobileUsageReport); return [ 'mba_id' => $mobileUsageReport['mba_id'], 'date' => $mobileUsageReport['date'], 'active' => $mobileUsageReport['active'], 'inactive' => $mobileUsageReport['inactive'], 'locked' => $mobileUsageReport['locked'], ]; }); // dd($this->loadLockedAccounts()); } else { $this->addError('mobile usage reports', 'Failed to load mobile usage report.'); } } catch (\Exception $e) { $this->addError('mobile usage reports', 'Error: ' . $e->getMessage()); } } public function render() { return view('livewire.report.mobile-usage-report', [ 'mobileUsageReport' => $this->mobileUsageReport, ]); } }