feature/api-adminstats-transactions #85
@@ -81,13 +81,11 @@ class StatisticsController extends Controller
|
||||
$totalGames = Game::count();
|
||||
$totalBlockedUsers = User::where('blocked', true)->count();
|
||||
|
||||
// 2. Games Breakdown by Type
|
||||
$gamesByType = Game::select('type', DB::raw('count(*) as total'))
|
||||
->groupBy('type')
|
||||
->get();
|
||||
|
||||
// 3. Games Per Month (CORRIGIDO PARA SQLITE)
|
||||
// SQLite usa strftime('%Y-%m', coluna) em vez de DATE_FORMAT
|
||||
|
||||
$gamesPerMonth = Game::select(
|
||||
DB::raw("strftime('%Y-%m', began_at) as month"),
|
||||
DB::raw('count(*) as total')
|
||||
@@ -98,13 +96,11 @@ class StatisticsController extends Controller
|
||||
->limit(12)
|
||||
->get();
|
||||
|
||||
// 4. Financial/Coin Stats
|
||||
$totalCoinsPurchased = \App\Models\CoinTransaction::whereHas('type', function($q) {
|
||||
$q->where('name', 'Coin purchase');
|
||||
})
|
||||
->sum('coins');
|
||||
|
||||
// Calculate Purchases Per Month (CORRIGIDO PARA SQLITE)
|
||||
$purchasesPerMonth = \App\Models\CoinTransaction::join('coin_transaction_types', 'coin_transactions.coin_transaction_type_id', '=', 'coin_transaction_types.id')
|
||||
->where('coin_transaction_types.name', 'Coin purchase')
|
||||
->select(
|
||||
|
||||
Reference in New Issue
Block a user