From 1830863f4bb2df876040ab57451c9835e0869280 Mon Sep 17 00:00:00 2001 From: yukidaruma Date: Sat, 14 Mar 2020 16:45:03 +0900 Subject: [PATCH] Add per-player filter criteria * Golden Eggs * Power Eggs * Special weapon Part of #5 --- app/UseCases/IndexResultUsecase.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/UseCases/IndexResultUsecase.php b/app/UseCases/IndexResultUsecase.php index 3834fee..c9de15c 100644 --- a/app/UseCases/IndexResultUsecase.php +++ b/app/UseCases/IndexResultUsecase.php @@ -73,6 +73,16 @@ function buildMax($column) ->whereIn('stage_id', explode(',', $value)), ]; + if ($results->getModel() instanceof SalmonPlayerResult) { + $filters += [ + 'player_min_golden_egg' => buildMin('golden_eggs'), + 'player_max_golden_egg' => buildMax('golden_eggs'), + 'player_min_power_egg' => buildMin('power_eggs'), + 'player_max_power_egg' => buildMax('power_eggs'), + 'special' => buildWhere('special_id', '='), + ]; + } + foreach ($filters as $key => $filter) { if (isset($query[$key])) { $results = $filter($results, $query[$key]);