user(); $wallet = $this->manager->walletFor($user); $codes = $user->qrCodes() ->whereIn('type', QrTypeCatalog::plusTypes()) ->latest() ->limit(5) ->get(); $activeCount = $user->qrCodes() ->whereIn('type', QrTypeCatalog::plusTypes()) ->where('is_active', true) ->count(); $scans30d = $user->qrCodes() ->whereIn('type', QrTypeCatalog::plusTypes()) ->withSum(['scanEvents as scans_30d' => fn ($q) => $q->where('created_at', '>=', now()->subDays(30))], 'id') ->get() ->sum('scans_30d'); return view('qr.dashboard', [ 'wallet' => $wallet, 'recentCodes' => $codes, 'activeCount' => $activeCount, 'scans30d' => (int) $scans30d, 'balanceMinor' => $this->billing->balanceMinor($user->public_id), ]); } }