Created statistics personal and general
This commit is contained in:
@@ -29,16 +29,23 @@ class StatisticsController extends Controller
|
||||
{
|
||||
$type = $request->query('type');
|
||||
|
||||
$query = User::where('type', 'P')
|
||||
$leaderboard = User::where('type', 'P')
|
||||
->withCount(['wonGames' => function ($query) use ($type) {
|
||||
if ($type) {
|
||||
$query->where('type', $type);
|
||||
}
|
||||
}])
|
||||
->orderBy('won_games_count', 'desc')
|
||||
->take(10);
|
||||
->paginate(10);
|
||||
|
||||
$leaderboard = $query->get(['id', 'nickname', 'photo_avatar_filename']);
|
||||
$leaderboard->through(function ($user) {
|
||||
return [
|
||||
'id' => $user->id,
|
||||
'nickname' => $user->nickname,
|
||||
'photo_avatar_filename' => $user->photo_avatar_filename,
|
||||
'won_games_count' => $user->won_games_count,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($leaderboard);
|
||||
}
|
||||
|
||||
@@ -53,4 +53,15 @@ Authorization: Bearer {{token}}
|
||||
"euros": 1,
|
||||
"payment_type": "MBWAY",
|
||||
"payment_reference": "912345678"
|
||||
}
|
||||
}
|
||||
|
||||
### Get public stats
|
||||
GET http://localhost:8000/api/v1/leaderboard
|
||||
Content-Type: application/json
|
||||
Accept: application/json
|
||||
|
||||
### Get me stats
|
||||
GET http://localhost:8000/api/v1/statistics/me
|
||||
Content-Type: application/json
|
||||
Accept: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
Reference in New Issue
Block a user