Skip to content

Commit

Permalink
Fix undefined total_points in getTopExperiencedPlayers
Browse files Browse the repository at this point in the history
Signed-off-by: pacoorozco <[email protected]>
  • Loading branch information
pacoorozco committed Jun 16, 2024
1 parent 07b8646 commit 2e55187
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions app/Libs/Game/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,16 @@ public static function getTopExperiencedPlayers(int $maxNumberOfPlayers = 10): C
{
return User::query()
->player()
->select(['username', 'name'])
->withSum('points as total_points', 'points')
->select(['username', 'name', 'level'])
->withSum('points', 'points as total_points')
->orderByDesc('total_points')
->take($maxNumberOfPlayers)
->limit($maxNumberOfPlayers)
->get()
->map(function ($user) {
return [
'username' => $user->username,
'name' => $user->name,
'experience' => $user->total_points ?? 0,
'level' => $user->level,
];
});
->map(fn($user) => [
'username' => $user->username,
'name' => $user->name,
'experience' => $user->experience ?? 0,
'level' => $user->level,
]);
}
}

0 comments on commit 2e55187

Please sign in to comment.