where('user_id', $account->id) ->pluck('id'); $downloads30d = TransferDownloadEvent::query() ->whereIn('transfer_id', $transferIds) ->where('downloaded_at', '>=', now()->subDays(30)) ->count(); $topTransfers = Transfer::query() ->where('user_id', $account->id) ->where('status', Transfer::STATUS_ACTIVE) ->orderByDesc('downloads_total') ->limit(10) ->get(); $recentDownloads = TransferDownloadEvent::query() ->whereIn('transfer_id', $transferIds) ->with(['transfer', 'file']) ->latest('downloaded_at') ->limit(20) ->get(); return view('transfer.analytics.index', [ 'downloads30d' => $downloads30d, 'topTransfers' => $topTransfers, 'recentDownloads' => $recentDownloads, ]); } }