where('amount', '>', 0) ->sum('amount'); $totalWithdrawals = WalletTransaction::where('status', 'completed') ->where('amount', '<', 0) ->sum(DB::raw('ABS(amount)')); $todayTransactions = WalletTransaction::whereDate('created_at', today())->count(); $activeWallets = Wallet::where('balance', '>', 0)->count(); $pendingTransactions = WalletTransaction::where('status', 'pending')->count(); $chartData = []; for ($i = 6; $i >= 0; $i--) { $date = now()->subDays($i)->format('Y-m-d'); $chartData[] = WalletTransaction::whereDate('created_at', $date) ->where('status', 'completed') ->sum('amount'); } return [ Stat::make('موجودی کل', number_format($totalBalance) . ' ریال') ->description('مجموع موجودی همه کاربران') ->descriptionIcon('heroicon-m-banknotes') ->color('success') ->chart($chartData), Stat::make('مجموع واریزی‌ها', number_format($totalDeposits) . ' ریال') ->description('کل مبالغ واریز شده موفق') ->descriptionIcon('heroicon-m-arrow-down-on-square') ->color('primary'), Stat::make('مجموع برداشت‌ها', number_format($totalWithdrawals) . ' ریال') ->description('کل مبالغ برداشت شده موفق') ->descriptionIcon('heroicon-m-arrow-up-on-square') ->color('danger'), Stat::make('تراکنش‌های امروز', number_format($todayTransactions)) ->description('تعداد تراکنش‌های ثبت‌شده در امروز') ->descriptionIcon('heroicon-m-calendar') ->color('info'), Stat::make('کیف پول‌های فعال', number_format($activeWallets)) ->description('کاربرانی با موجودی مثبت') ->descriptionIcon('heroicon-m-user-group') ->color('success'), Stat::make('در انتظار بررسی', number_format($pendingTransactions)) ->description('تراکنش‌های نیاز به تأیید') ->descriptionIcon('heroicon-m-clock') ->color($pendingTransactions > 0 ? 'warning' : 'gray'), ]; } }