Update scoring for 2022 show
This commit is contained in:
parent
aa7909b4d5
commit
cabf4a48d3
@ -46,9 +46,9 @@ class TabulateWinners extends Command
|
|||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
function mainWinner()
|
function bestInShowWinner()
|
||||||
{
|
{
|
||||||
$mainWinnerQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
|
$bestInShowWinnerQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
|
||||||
->groupBy('vehicles.id')
|
->groupBy('vehicles.id')
|
||||||
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
|
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
|
||||||
->whereNotIn('vehicle_scores.vehicle', function($query){
|
->whereNotIn('vehicle_scores.vehicle', function($query){
|
||||||
@ -57,7 +57,7 @@ class TabulateWinners extends Command
|
|||||||
->where('vehicles.doNotJudge', '=', 0)
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
->orderBy('totalscore','desc')
|
->orderBy('totalscore','desc')
|
||||||
->first();
|
->first();
|
||||||
return $mainWinnerQuery->vehicle;
|
return $bestInShowWinnerQuery->vehicle;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pcWinner()
|
function pcWinner()
|
||||||
@ -74,130 +74,38 @@ class TabulateWinners extends Command
|
|||||||
return $peoplesChoiceWinnerQuery->vehicle;
|
return $peoplesChoiceWinnerQuery->vehicle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function zeroTo43Winner()
|
||||||
function oughtsTo49Winner()
|
|
||||||
{
|
{
|
||||||
$oughtsTo49Query = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
|
$zeroTo43Query = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
|
||||||
->groupBy('vehicles.id')
|
->groupBy('vehicles.id')
|
||||||
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
|
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
|
||||||
->whereNotIn('vehicle_scores.vehicle', function($query){
|
->whereNotIn('vehicle_scores.vehicle', function($query){
|
||||||
$query->select('vehicle')->from('car_show_winners');
|
$query->select('vehicle')->from('car_show_winners');
|
||||||
})
|
})
|
||||||
->where('vehicles.year', '>=', 1900)
|
->where('vehicles.year', '>=', 0)
|
||||||
->where('vehicles.year', '<=', 1949)
|
->where('vehicles.year', '<=', 1943)
|
||||||
->where('vehicles.doNotJudge', '=', 0)
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
->orderBy('totalscore','desc')
|
->orderBy('totalscore','desc')
|
||||||
->first();
|
->first();
|
||||||
return $oughtsTo49Query->vehicle;
|
return $zeroTo43Query->vehicle;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fiftiesWinner()
|
function fortyFourToCurrentWinner()
|
||||||
{
|
{
|
||||||
$fiftiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
|
$fortyFourToCurrentQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
|
||||||
->groupBy('vehicles.id')
|
->groupBy('vehicles.id')
|
||||||
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
|
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
|
||||||
->whereNotIn('vehicle_scores.vehicle', function($query){
|
->whereNotIn('vehicle_scores.vehicle', function($query){
|
||||||
$query->select('vehicle')->from('car_show_winners');
|
$query->select('vehicle')->from('car_show_winners');
|
||||||
})
|
})
|
||||||
->where('vehicles.year', '>=', 1950)
|
->where('vehicles.year', '>=', 1944)
|
||||||
->where('vehicles.year', '<=', 1959)
|
|
||||||
->where('vehicles.doNotJudge', '=', 0)
|
|
||||||
->orderBy('totalscore','desc')
|
|
||||||
->first();
|
|
||||||
return $fiftiesQuery->vehicle;
|
|
||||||
}
|
|
||||||
|
|
||||||
function sixtiesWinner()
|
|
||||||
{
|
|
||||||
$sixtiesQuery = 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.year', '>=', 1960)
|
|
||||||
->where('vehicles.year', '<=', 1969)
|
|
||||||
->where('vehicles.doNotJudge', '=', 0)
|
|
||||||
->orderBy('totalscore','desc')
|
|
||||||
->first();
|
|
||||||
return $sixtiesQuery->vehicle;
|
|
||||||
}
|
|
||||||
function seventiesWinner()
|
|
||||||
{
|
|
||||||
$seventiesQuery = 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.year', '>=', 1970)
|
|
||||||
->where('vehicles.year', '<=', 1979)
|
|
||||||
->where('vehicles.doNotJudge', '=', 0)
|
|
||||||
->orderBy('totalscore','desc')
|
|
||||||
->first();
|
|
||||||
return $seventiesQuery->vehicle;
|
|
||||||
}
|
|
||||||
|
|
||||||
function eightiesWinner()
|
|
||||||
{
|
|
||||||
$eightiesQuery = 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.year', '>=', 1980)
|
|
||||||
->where('vehicles.year', '<=', 1989)
|
|
||||||
->where('vehicles.doNotJudge', '=', 0)
|
|
||||||
->orderBy('totalscore','desc')
|
|
||||||
->first();
|
|
||||||
return $eightiesQuery->vehicle;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ninetiesWinner()
|
|
||||||
{
|
|
||||||
$ninetiesQuery = 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.year', '>=', 1990)
|
|
||||||
->where('vehicles.year', '<=', 1999)
|
|
||||||
->where('vehicles.doNotJudge', '=', 0)
|
|
||||||
->orderBy('totalscore','desc')
|
|
||||||
->first();
|
|
||||||
return $ninetiesQuery->vehicle;
|
|
||||||
}
|
|
||||||
function thousandsWinner()
|
|
||||||
{
|
|
||||||
$thousandsQuery = 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.year', '>=', 2000)
|
|
||||||
//->where('vehicles.year', '<=', 1959)
|
//->where('vehicles.year', '<=', 1959)
|
||||||
->where('vehicles.doNotJudge', '=', 0)
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
->orderBy('totalscore','desc')
|
->orderBy('totalscore','desc')
|
||||||
->first();
|
->first();
|
||||||
return $thousandsQuery->vehicle;
|
return $fortyFourToCurrentQuery->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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//categories
|
//categories
|
||||||
/* Here for reference only
|
/* Here for reference only
|
||||||
$individuallyProcessedAwards = array(
|
$individuallyProcessedAwards = array(
|
||||||
@ -205,30 +113,16 @@ class TabulateWinners extends Command
|
|||||||
'pcFirst' => '3'
|
'pcFirst' => '3'
|
||||||
); */
|
); */
|
||||||
$mainAwardsToCalculate = array(
|
$mainAwardsToCalculate = array(
|
||||||
// 'inShowFirst' =>'6',
|
'inShowFirst' =>'6',
|
||||||
// 'pcFirst' => '3',
|
'inShowSecond' =>'6',
|
||||||
'bestTruckFirst' => '5',
|
'pcFirst' => '3',
|
||||||
'corvetteFirst' => '7',
|
'pcSecond' => '3'
|
||||||
'camaroFirst' => '8',
|
|
||||||
// 'moparFirst' => '16',
|
|
||||||
'mustangFirst' => '1',
|
|
||||||
'ratRideFirst' => '4'
|
|
||||||
);
|
);
|
||||||
$yearAwardsToCalculate = array(
|
$yearAwardsToCalculate = array(
|
||||||
'oughtsTo49First' => '9',
|
'zeroTo43First' => '17',
|
||||||
'oughtsTo49Second' => '9',
|
'zeroTo43Second' => '17',
|
||||||
'fiftiesFirst' => '10',
|
'fourtyFourToCurrentFirst' => '18',
|
||||||
'fiftiesSecond' => '10',
|
'fourtyFourToCurrentSecond' => '18'
|
||||||
'sixtiesFirst' => '11',
|
|
||||||
'sixtiesSecond' => '11',
|
|
||||||
'seventiesFirst' => '12',
|
|
||||||
'seventiesSecond' => '12',
|
|
||||||
'eightiesFirst' => '13',
|
|
||||||
'eightiesSecond' => '13',
|
|
||||||
'ninetiesFirst' => '14',
|
|
||||||
'ninetiesSecond' => '14',
|
|
||||||
'thousandsFirst' => '15',
|
|
||||||
'thousandsSecond' => '15'
|
|
||||||
);
|
);
|
||||||
//Insert Best In Show Winner
|
//Insert Best In Show Winner
|
||||||
CarShowWinner::updateOrCreate(
|
CarShowWinner::updateOrCreate(
|
||||||
@ -237,174 +131,80 @@ class TabulateWinners extends Command
|
|||||||
'place' => 'first'
|
'place' => 'first'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'vehicle' => mainWinner()
|
'vehicle' => bestInShowWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
//Insert Best In Show 2nd Place Winner
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '6',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => bestInShowWinner()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
//Insert People's Choice Winner
|
//Insert People's Choice Winner
|
||||||
/*CarShowWinner::updateOrCreate(
|
CarShowWinner::updateOrCreate(
|
||||||
[
|
[
|
||||||
'category' => '3',
|
'category' => '3',
|
||||||
'place' => 'first'
|
'place' => 'first'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'vehicle' => $peoplesChoiceWinnerQuery
|
'vehicle' => pcWinner()
|
||||||
]
|
|
||||||
);*/
|
|
||||||
//Insert Category Award Winners
|
|
||||||
foreach($mainAwardsToCalculate as $mainaward => $category) {
|
|
||||||
$categorywinner = CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => $category,
|
|
||||||
'place' => 'first'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => categoryWinner($category)
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '3',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => pcWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
//Insert Year Award Winners
|
//Insert Year Award Winners
|
||||||
//1900-1949
|
//0-1943
|
||||||
CarShowWinner::updateOrCreate(
|
CarShowWinner::updateOrCreate(
|
||||||
[
|
[
|
||||||
'category' => '9',
|
'category' => '17',
|
||||||
'place' => 'first'
|
'place' => 'first'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'vehicle' => oughtsTo49Winner()
|
'vehicle' => zeroTo43Winner()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
CarShowWinner::updateOrCreate(
|
CarShowWinner::updateOrCreate(
|
||||||
[
|
[
|
||||||
'category' => '9',
|
'category' => '17',
|
||||||
'place' => 'second'
|
'place' => 'second'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'vehicle' => oughtsTo49Winner()
|
'vehicle' => zeroTo43Winner()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//1950-1959
|
//1944-Current
|
||||||
CarShowWinner::updateOrCreate(
|
CarShowWinner::updateOrCreate(
|
||||||
[
|
[
|
||||||
'category' => '10',
|
'category' => '18',
|
||||||
'place' => 'first'
|
'place' => 'first'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'vehicle' => fiftiesWinner()
|
'vehicle' => fortyFourToCurrentWinner()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
CarShowWinner::updateOrCreate(
|
CarShowWinner::updateOrCreate(
|
||||||
[
|
[
|
||||||
'category' => '10',
|
'category' => '18',
|
||||||
'place' => 'second'
|
'place' => 'second'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'vehicle' => fiftiesWinner()
|
'vehicle' => fortyFourToCurrentWinner()
|
||||||
]
|
|
||||||
);
|
|
||||||
//1960-1969
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '11',
|
|
||||||
'place' => 'first'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => sixtiesWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '11',
|
|
||||||
'place' => 'second'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => sixtiesWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
//1970-1979
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '12',
|
|
||||||
'place' => 'first'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => seventiesWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '12',
|
|
||||||
'place' => 'second'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => seventiesWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
//1980-1989
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '13',
|
|
||||||
'place' => 'first'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => eightiesWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '13',
|
|
||||||
'place' => 'second'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => eightiesWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
//1990-1999
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '14',
|
|
||||||
'place' => 'first'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => ninetiesWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '14',
|
|
||||||
'place' => 'second'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => ninetiesWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
//2000-present
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '15',
|
|
||||||
'place' => 'first'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => thousandsWinner()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
CarShowWinner::updateOrCreate(
|
|
||||||
[
|
|
||||||
'category' => '15',
|
|
||||||
'place' => 'second'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vehicle' => thousandsWinner()
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
411
app/Console/Commands/TabulateWinners.php.bak
Normal file
411
app/Console/Commands/TabulateWinners.php.bak
Normal file
@ -0,0 +1,411 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use App\Models\Bidders;
|
||||||
|
use App\Models\CarShowCategory;
|
||||||
|
use App\Models\CarShowWinner;
|
||||||
|
use App\Models\PeoplesChoice;
|
||||||
|
use App\Models\Vehicles;
|
||||||
|
use App\Models\VehicleScores;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
|
||||||
|
class TabulateWinners extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'carshow:tabulatewinners';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Tabulate Show Winners, and add them to the CarShowWinner table';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
function mainWinner()
|
||||||
|
{
|
||||||
|
$mainWinnerQuery = 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)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $mainWinnerQuery->vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pcWinner()
|
||||||
|
{
|
||||||
|
$peoplesChoiceWinnerQuery = DB::table('peoples_choice')
|
||||||
|
->groupBy('peoples_choice.vehicle')
|
||||||
|
->selectRaw('*, sum(pc_count as totalscore')
|
||||||
|
->whereNotIn('vehicle', function($query){
|
||||||
|
$query->select('vehicle')->from('car_show_winners');
|
||||||
|
})
|
||||||
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $peoplesChoiceWinnerQuery->vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function oughtsTo49Winner()
|
||||||
|
{
|
||||||
|
$oughtsTo49Query = 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.year', '>=', 1900)
|
||||||
|
->where('vehicles.year', '<=', 1949)
|
||||||
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $oughtsTo49Query->vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fiftiesWinner()
|
||||||
|
{
|
||||||
|
$fiftiesQuery = 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.year', '>=', 1950)
|
||||||
|
->where('vehicles.year', '<=', 1959)
|
||||||
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $fiftiesQuery->vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sixtiesWinner()
|
||||||
|
{
|
||||||
|
$sixtiesQuery = 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.year', '>=', 1960)
|
||||||
|
->where('vehicles.year', '<=', 1969)
|
||||||
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $sixtiesQuery->vehicle;
|
||||||
|
}
|
||||||
|
function seventiesWinner()
|
||||||
|
{
|
||||||
|
$seventiesQuery = 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.year', '>=', 1970)
|
||||||
|
->where('vehicles.year', '<=', 1979)
|
||||||
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $seventiesQuery->vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function eightiesWinner()
|
||||||
|
{
|
||||||
|
$eightiesQuery = 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.year', '>=', 1980)
|
||||||
|
->where('vehicles.year', '<=', 1989)
|
||||||
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $eightiesQuery->vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ninetiesWinner()
|
||||||
|
{
|
||||||
|
$ninetiesQuery = 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.year', '>=', 1990)
|
||||||
|
->where('vehicles.year', '<=', 1999)
|
||||||
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $ninetiesQuery->vehicle;
|
||||||
|
}
|
||||||
|
function thousandsWinner()
|
||||||
|
{
|
||||||
|
$thousandsQuery = 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.year', '>=', 2000)
|
||||||
|
//->where('vehicles.year', '<=', 1959)
|
||||||
|
->where('vehicles.doNotJudge', '=', 0)
|
||||||
|
->orderBy('totalscore','desc')
|
||||||
|
->first();
|
||||||
|
return $thousandsQuery->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;
|
||||||
|
}
|
||||||
|
//categories
|
||||||
|
/* Here for reference only
|
||||||
|
$individuallyProcessedAwards = array(
|
||||||
|
'inShowFirst' =>'6',
|
||||||
|
'pcFirst' => '3'
|
||||||
|
); */
|
||||||
|
$mainAwardsToCalculate = array(
|
||||||
|
// 'inShowFirst' =>'6',
|
||||||
|
// 'pcFirst' => '3',
|
||||||
|
'bestTruckFirst' => '5',
|
||||||
|
'corvetteFirst' => '7',
|
||||||
|
'camaroFirst' => '8',
|
||||||
|
// 'moparFirst' => '16',
|
||||||
|
'mustangFirst' => '1',
|
||||||
|
'ratRideFirst' => '4'
|
||||||
|
);
|
||||||
|
$yearAwardsToCalculate = array(
|
||||||
|
'oughtsTo49First' => '9',
|
||||||
|
'oughtsTo49Second' => '9',
|
||||||
|
'fiftiesFirst' => '10',
|
||||||
|
'fiftiesSecond' => '10',
|
||||||
|
'sixtiesFirst' => '11',
|
||||||
|
'sixtiesSecond' => '11',
|
||||||
|
'seventiesFirst' => '12',
|
||||||
|
'seventiesSecond' => '12',
|
||||||
|
'eightiesFirst' => '13',
|
||||||
|
'eightiesSecond' => '13',
|
||||||
|
'ninetiesFirst' => '14',
|
||||||
|
'ninetiesSecond' => '14',
|
||||||
|
'thousandsFirst' => '15',
|
||||||
|
'thousandsSecond' => '15'
|
||||||
|
);
|
||||||
|
//Insert Best In Show Winner
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '6',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => mainWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
//Insert People's Choice Winner
|
||||||
|
/*CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '3',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => $peoplesChoiceWinnerQuery
|
||||||
|
]
|
||||||
|
);*/
|
||||||
|
//Insert Category Award Winners
|
||||||
|
foreach($mainAwardsToCalculate as $mainaward => $category) {
|
||||||
|
$categorywinner = CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => $category,
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => categoryWinner($category)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Insert Year Award Winners
|
||||||
|
//1900-1949
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '9',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => oughtsTo49Winner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '9',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => oughtsTo49Winner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
//1950-1959
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '10',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => fiftiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '10',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => fiftiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
//1960-1969
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '11',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => sixtiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '11',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => sixtiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
//1970-1979
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '12',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => seventiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '12',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => seventiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
//1980-1989
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '13',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => eightiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '13',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => eightiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
//1990-1999
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '14',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => ninetiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '14',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => ninetiesWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
//2000-present
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '15',
|
||||||
|
'place' => 'first'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => thousandsWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
CarShowWinner::updateOrCreate(
|
||||||
|
[
|
||||||
|
'category' => '15',
|
||||||
|
'place' => 'second'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle' => thousandsWinner()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -146,6 +146,11 @@
|
|||||||
Car Show Winners
|
Car Show Winners
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="/showscores">
|
||||||
|
Vehicle Total Scores
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
|
Loading…
Reference in New Issue
Block a user