fix winner tabultation

This commit is contained in:
Russ Long 2020-02-08 15:02:53 -05:00
parent f35c0d9658
commit 1ce40b0eb0

View File

@ -58,7 +58,20 @@ class TabulateWinners extends Command
->first(); ->first();
return $mainWinnerQuery->vehicle; return $mainWinnerQuery->vehicle;
} }
function categoryWinner($category)
{
$categoryWinnerQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function ($query) {
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.doNotJudge', '=', '0')
->where('vehicles.type', '=', "$category")
->orderBy('totalscore', 'desc')
->first();
return $categoryWinnerQuery->vehicle;
}
function pcWinner() function pcWinner()
@ -238,7 +251,7 @@ class TabulateWinners extends Command
'place' => 'first' 'place' => 'first'
], ],
[ [
'vehicle' => mainWinner() 'vehicle' => categoryWinner($category)
] ]
); );
} }