Q:

Laravel Query Builder - return the max value of combined entries

With Laravel's query builder, I am trying to get the combined highest scores for a specific game.
I currently have my method below which finds the single highest score for the game.
public function getHighestScore()
{
    return DB::table('scores')
        ->join('games', 'scores.game_id', '=', 'games.id')
        ->join('users', 'scores.user_id', '=', 'users.id')
        ->select('scores.score as return')
        ->where('scores.game_id', $this->id)
        ->get()->max('return');
}

So calling
$game = Game::find(5);
$game->getHighestScore();

Correctly outputs
784

However now I need to be able to get the highest (combined users scores) for a game AND get that user by id.
I would really like to achieve this with one single query if possible?
My scores table can be shown below:
+---------+----------+----------+--------+
| id      | game_id  | user_id  | score  |
+---------+----------+----------+--------+
| 97      |        5 |        3 |    234 |
| 123     |        3 |        3 |    102 |
| 300     |        5 |        1 |     99 |
| 422     |        5 |        1 |    784 |
| 531     |        5 |        3 |    221 |
| 612     |        3 |        3 |    222 |
| 798     |        3 |        3 |    379 |
+---------+----------+----------+--------+

So something like:
$game = Game::find(5);
$game->getUserWithHighestCombinedScore();

Is this possible?
What would my query have to include?
To help clarify I have included the below.
If you were to combine the user_id's score per game the hypothetical table would look like so:
+---------+----------+----------+-----------------+
| id      | game_id  | user_id  | combined_score  |
+---------+----------+----------+-----------------+
|         |        5 |        3 |             455 | 
|         |        5 |        1 |             883 |  
|         |        3 |        3 |             703 |  
+---------+----------+----------+-----------------+

And calling something ideally like
$game->getUserWithHighestCombinedScore();

Would return both
// user_id
1
// combined_score of
883

SO they would need to be within the ->select() attributes.
Is this possible?

A:

So firstly, for your first query, I do not think you need that many joins you can just simply do this.
return DB::table('scores')->where('game_id', $this->id)->max('score');

And then for your question, I think this should work.
    return DB::table('scores')
        ->where('game_id', $this->id)
        ->select('user_id', DB::raw('SUM(score) as total'))
        ->groupBy('user_id')
        ->orderByDesc('Total')
        ->take(1)
        ->get();

