Skip to content

Commit

Permalink
Add support for weapons filter
Browse files Browse the repository at this point in the history
Part of #5
  • Loading branch information
yukidaruma committed Mar 14, 2020
1 parent 1830863 commit 49266d0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/UseCases/IndexResultUsecase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ public function __invoke($playerId = null, $scheduleTimestamp = null, String $ro

$results = $results
->with(['weapons'])
->distinct('salmon_results.id')
->select(
'*',
'salmon_player_results.*',
'salmon_results.*',
'salmon_results.boss_elimination_count as boss_elimination_count',
'salmon_player_results.boss_elimination_count as player_boss_elimination_count',
)
->where('player_id', $playerId);
->where('salmon_player_results.player_id', $playerId);

if (!is_null($scheduleTimestamp)) {
$results = $results->where('schedule_id', $scheduleTimestamp);
Expand Down Expand Up @@ -80,6 +82,13 @@ function buildMax($column)
'player_min_power_egg' => buildMin('power_eggs'),
'player_max_power_egg' => buildMax('power_eggs'),
'special' => buildWhere('special_id', '='),
'weapons' => fn ($results, $value) => $results
->join('salmon_player_weapons', function ($join) use ($value) {
$join
->on('salmon_player_weapons.player_id', 'salmon_player_results.player_id')
->on('salmon_player_weapons.salmon_id', 'salmon_results.id')
->whereIn('weapon_id', explode(',', $value));
}),
];
}

Expand Down

0 comments on commit 49266d0

Please sign in to comment.