manager->walletFor($account); $codes = $account->qrCodes() ->whereIn('type', QrTypeCatalog::plusTypes()) ->latest() ->limit(5) ->get(); $activeCount = $account->qrCodes() ->whereIn('type', QrTypeCatalog::plusTypes()) ->where('is_active', true) ->count(); $scans30d = $account->qrCodes() ->whereIn('type', QrTypeCatalog::plusTypes()) ->withSum(['scanEvents as scans_30d' => fn ($q) => $q->where('created_at', '>=', now()->subDays(30))], 'id') ->get() ->sum('scans_30d'); $balanceMinor = 0; try { $balanceMinor = $this->billing->balanceMinor($account->public_id); } catch (Throwable $e) { Log::warning('QR Plus dashboard could not load wallet balance', [ 'user' => $account->public_id, 'error' => $e->getMessage(), ]); } return view('qr.dashboard', [ 'wallet' => $wallet, 'recentCodes' => $codes, 'activeCount' => $activeCount, 'scans30d' => (int) $scans30d, 'balanceMinor' => $balanceMinor, 'pricePerQr' => QrWallet::pricePerQr(), ]); } }