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