cleanup old winner tabulation

This commit is contained in:
2026-04-20 10:15:08 -04:00
parent a99021587e
commit 472cb78ffb
6 changed files with 408 additions and 418 deletions
+98 -286
View File
@@ -3,307 +3,119 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use App\Models\Bidders;
use App\Models\CarShowCategory;
use App\Models\CarShowWinner; use App\Models\CarShowWinner;
use App\Models\PeoplesChoice; use App\Models\PeoplesChoice;
use App\Models\Vehicles;
use App\Models\VehicleScores; use App\Models\VehicleScores;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class TabulateWinners extends Command class TabulateWinners extends Command
{ {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'carshow:tabulatewinners'; protected $signature = 'carshow:tabulatewinners';
protected $description = 'Tabulate Show Winners. Year Category 1st places can overlap with Best in Show/People\'s Choice.';
/**
* 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() public function handle()
{ {
function bestInShowWinner()
{
$bestInShowWinnerQuery = 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 $bestInShowWinnerQuery->vehicle;
}
function bestInShow2ndWinner()
{
$bestInShow2ndWinnerQuery = 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 $bestInShow2ndWinnerQuery->vehicle;
}
function pcWinner()
{
$peoplesChoiceWinnerQuery = PeoplesChoice::join('vehicles', 'peoples_choice.vehicle', '=', 'vehicles.id')
->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 pc2ndWinner()
{
$peoplesChoice2ndWinnerQuery = PeoplesChoice::join('vehicles', 'peoples_choice.vehicle', '=', 'vehicles.id')
->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 $peoplesChoice2ndWinnerQuery->vehicle;
}
function zeroTo42Winner()
{
$zeroTo43Query = 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', '>=', 0)
->where('vehicles.year', '<=', 1942)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $zeroTo43Query->vehicle;
}
function fortyThreeToSixtyNineWinner()
{
$fortyThreeToSixtyNineQuery = 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', '>=', 1943)
->where('vehicles.year', '<=', 1969)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $fortyThreeToSixtyNineQuery->vehicle;
}
function seventyToTwoThousandWinner()
{
$seventyToTwoThousandQuery = 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', '<=', 2000)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $seventyToTwoThousandQuery->vehicle;
}
function TwoThousandOneToCurrentWinner()
{
$TwoThousandOneToCurrentQuery = 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', '>=', 2001)
//->where('vehicles.year', '<=', 1997)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $TwoThousandOneToCurrentQuery->vehicle;
}
// Truncate table first
CarShowWinner::truncate(); CarShowWinner::truncate();
//Insert Best In Show Winner
CarShowWinner::updateOrCreate(
[
'category' => '6',
'place' => 'first'
],
[
'vehicle' => bestInShowWinner()
]
);
//Insert People's Choice Winner $this->info('Starting tabulation...');
CarShowWinner::updateOrCreate(
[
'category' => '3',
'place' => 'first'
],
[
'vehicle' => pcWinner()
]
);
//Insert Year Award Winners // 2. BEST IN SHOW (Category 6)
//0-1942 $this->recordJudgedWinners(6, 'first', null, null, true);
CarShowWinner::updateOrCreate(
[
'category' => '17',
'place' => 'first'
],
[
'vehicle' => zeroTo42Winner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '17',
'place' => 'second'
],
[
'vehicle' => zeroTo42Winner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '17',
'place' => 'third'
],
[
'vehicle' => zeroTo42Winner()
]
);
//1943-1969
CarShowWinner::updateOrCreate(
[
'category' => '18',
'place' => 'first'
],
[
'vehicle' => fortyThreeToSixtyNineWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '18',
'place' => 'second'
],
[
'vehicle' => fortyThreeToSixtyNineWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '18',
'place' => 'third'
],
[
'vehicle' => fortyThreeToSixtyNineWinner()
]
);
//1970-2000 // 3. PEOPLE'S CHOICE (Category 3)
CarShowWinner::updateOrCreate( $this->recordPeoplesChoiceWinners(3, 'first');
[
'category' => '20',
'place' => 'first'
],
[
'vehicle' => seventyToTwoThousandWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '20',
'place' => 'second'
],
[
'vehicle' => seventyToTwoThousandWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '20',
'place' => 'third'
],
[
'vehicle' => seventyToTwoThousandWinner()
]
);
//2001-Current // 4. YEAR CATEGORIES
CarShowWinner::updateOrCreate( $yearConfigs = [
[ ['id' => 17, 'name' => '0-1942', 'start' => 0, 'end' => 1942],
'category' => '19', ['id' => 18, 'name' => '1943-1969', 'start' => 1943, 'end' => 1969],
'place' => 'first' ['id' => 20, 'name' => '1970-2000', 'start' => 1970, 'end' => 2000],
], ['id' => 19, 'name' => '2001-Current', 'start' => 2001, 'end' => 2026],
[ ];
'vehicle' => TwoThousandOneToCurrentWinner()
] foreach ($yearConfigs as $config) {
); $this->info("Processing Category: {$config['name']}");
CarShowWinner::updateOrCreate( $this->recordJudgedWinners($config['id'], 'first', $config['start'], $config['end'], false);
[ $this->recordJudgedWinners($config['id'], 'second', $config['start'], $config['end'], true);
'category' => '19', $this->recordJudgedWinners($config['id'], 'third', $config['start'], $config['end'], true);
'place' => 'second' $this->recordJudgedWinners($config['id'], 'fourth', $config['start'], $config['end'], true);
], $this->recordJudgedWinners($config['id'], 'fifth', $config['start'], $config['end'], true);
[ }
'vehicle' => TwoThousandOneToCurrentWinner()
] $this->info('Winners tabulated successfully.');
); }
CarShowWinner::updateOrCreate(
[ private function recordJudgedWinners($categoryId, $place, $startYear = null, $endYear = null, $excludeExisting = true)
'category' => '19', {
'place' => 'third' $query = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
], ->where('vehicles.doNotJudge', 0);
[
'vehicle' => TwoThousandOneToCurrentWinner() if ($excludeExisting) {
] $query->whereNotIn('vehicle_scores.vehicle', function ($q) {
); $q->select('vehicle')->from('car_show_winners');
});
}
if ($startYear !== null) $query->where('vehicles.year', '>=', $startYear);
if ($endYear !== null) $query->where('vehicles.year', '<=', $endYear);
$maxScore = (clone $query)
->groupBy('vehicles.id')
->selectRaw('sum(vehicle_scores.overall_score) as totalscore')
->orderBy('totalscore', 'desc')
->value('totalscore');
if ($maxScore) {
$winners = $query->selectRaw('vehicles.id as vehicle_id, sum(vehicle_scores.overall_score) as totalscore')
->groupBy('vehicles.id')
->having('totalscore', '=', $maxScore)
->get();
foreach ($winners as $winner) {
CarShowWinner::updateOrCreate([
'category' => $categoryId,
'place' => $place,
'vehicle' => $winner->vehicle_id
], [
// Added totalscore here
'total_score' => $winner->totalscore
]);
}
}
}
private function recordPeoplesChoiceWinners($categoryId, $place)
{
$maxVotes = PeoplesChoice::join('vehicles', 'peoples_choice.vehicle', '=', 'vehicles.id')
->where('vehicles.doNotJudge', 0)
->whereNotIn('peoples_choice.vehicle', function ($q) {
$q->select('vehicle')->from('car_show_winners');
})
->groupBy('peoples_choice.vehicle')
->selectRaw('sum(pc_count) as totalvotes')
->orderBy('totalvotes', 'desc')
->value('totalvotes');
if ($maxVotes) {
$winners = PeoplesChoice::join('vehicles', 'peoples_choice.vehicle', '=', 'vehicles.id')
->selectRaw('peoples_choice.vehicle as vehicle_id, sum(pc_count) as totalvotes')
->where('vehicles.doNotJudge', 0)
->whereNotIn('peoples_choice.vehicle', function ($q) {
$q->select('vehicle')->from('car_show_winners');
})
->groupBy('peoples_choice.vehicle')
->having('totalvotes', '=', $maxVotes)
->get();
foreach ($winners as $winner) {
CarShowWinner::create([
'category' => $categoryId,
'place' => $place,
'vehicle' => $winner->vehicle_id,
// Added totalvotes here
'total_score' => $winner->totalvotes
]);
}
}
} }
} }
@@ -0,0 +1,309 @@
<?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 bestInShowWinner()
{
$bestInShowWinnerQuery = 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 $bestInShowWinnerQuery->vehicle;
}
function bestInShow2ndWinner()
{
$bestInShow2ndWinnerQuery = 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 $bestInShow2ndWinnerQuery->vehicle;
}
function pcWinner()
{
$peoplesChoiceWinnerQuery = PeoplesChoice::join('vehicles', 'peoples_choice.vehicle', '=', 'vehicles.id')
->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 pc2ndWinner()
{
$peoplesChoice2ndWinnerQuery = PeoplesChoice::join('vehicles', 'peoples_choice.vehicle', '=', 'vehicles.id')
->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 $peoplesChoice2ndWinnerQuery->vehicle;
}
function zeroTo42Winner()
{
$zeroTo43Query = 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', '>=', 0)
->where('vehicles.year', '<=', 1942)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $zeroTo43Query->vehicle;
}
function fortyThreeToSixtyNineWinner()
{
$fortyThreeToSixtyNineQuery = 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', '>=', 1943)
->where('vehicles.year', '<=', 1969)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $fortyThreeToSixtyNineQuery->vehicle;
}
function seventyToTwoThousandWinner()
{
$seventyToTwoThousandQuery = 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', '<=', 2000)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $seventyToTwoThousandQuery->vehicle;
}
function TwoThousandOneToCurrentWinner()
{
$TwoThousandOneToCurrentQuery = 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', '>=', 2001)
//->where('vehicles.year', '<=', 1997)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $TwoThousandOneToCurrentQuery->vehicle;
}
// Truncate table first
CarShowWinner::truncate();
//Insert Best In Show Winner
CarShowWinner::updateOrCreate(
[
'category' => '6',
'place' => 'first'
],
[
'vehicle' => bestInShowWinner()
]
);
//Insert People's Choice Winner
CarShowWinner::updateOrCreate(
[
'category' => '3',
'place' => 'first'
],
[
'vehicle' => pcWinner()
]
);
//Insert Year Award Winners
//0-1942
CarShowWinner::updateOrCreate(
[
'category' => '17',
'place' => 'first'
],
[
'vehicle' => zeroTo42Winner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '17',
'place' => 'second'
],
[
'vehicle' => zeroTo42Winner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '17',
'place' => 'third'
],
[
'vehicle' => zeroTo42Winner()
]
);
//1943-1969
CarShowWinner::updateOrCreate(
[
'category' => '18',
'place' => 'first'
],
[
'vehicle' => fortyThreeToSixtyNineWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '18',
'place' => 'second'
],
[
'vehicle' => fortyThreeToSixtyNineWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '18',
'place' => 'third'
],
[
'vehicle' => fortyThreeToSixtyNineWinner()
]
);
//1970-2000
CarShowWinner::updateOrCreate(
[
'category' => '20',
'place' => 'first'
],
[
'vehicle' => seventyToTwoThousandWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '20',
'place' => 'second'
],
[
'vehicle' => seventyToTwoThousandWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '20',
'place' => 'third'
],
[
'vehicle' => seventyToTwoThousandWinner()
]
);
//2001-Current
CarShowWinner::updateOrCreate(
[
'category' => '19',
'place' => 'first'
],
[
'vehicle' => TwoThousandOneToCurrentWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '19',
'place' => 'second'
],
[
'vehicle' => TwoThousandOneToCurrentWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '19',
'place' => 'third'
],
[
'vehicle' => TwoThousandOneToCurrentWinner()
]
);
}
}
-121
View File
@@ -1,121 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\CarShowWinner;
use App\Models\PeoplesChoice;
use App\Models\VehicleScores;
use Illuminate\Support\Facades\DB;
class TabulateWinnersNew extends Command
{
protected $signature = 'carshow:tabulatewinnersnew';
protected $description = 'Tabulate Show Winners. Year Category 1st places can overlap with Best in Show/People\'s Choice.';
public function handle()
{
CarShowWinner::truncate();
$this->info('Starting tabulation...');
// 2. BEST IN SHOW (Category 6)
$this->recordJudgedWinners(6, 'first', null, null, true);
// 3. PEOPLE'S CHOICE (Category 3)
$this->recordPeoplesChoiceWinners(3, 'first');
// 4. YEAR CATEGORIES
$yearConfigs = [
['id' => 17, 'name' => '0-1942', 'start' => 0, 'end' => 1942],
['id' => 18, 'name' => '1943-1969', 'start' => 1943, 'end' => 1969],
['id' => 20, 'name' => '1970-2000', 'start' => 1970, 'end' => 2000],
['id' => 19, 'name' => '2001-Current', 'start' => 2001, 'end' => 2026],
];
foreach ($yearConfigs as $config) {
$this->info("Processing Category: {$config['name']}");
$this->recordJudgedWinners($config['id'], 'first', $config['start'], $config['end'], false);
$this->recordJudgedWinners($config['id'], 'second', $config['start'], $config['end'], true);
$this->recordJudgedWinners($config['id'], 'third', $config['start'], $config['end'], true);
$this->recordJudgedWinners($config['id'], 'fourth', $config['start'], $config['end'], true);
$this->recordJudgedWinners($config['id'], 'fifth', $config['start'], $config['end'], true);
}
$this->info('Winners tabulated successfully.');
}
private function recordJudgedWinners($categoryId, $place, $startYear = null, $endYear = null, $excludeExisting = true)
{
$query = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->where('vehicles.doNotJudge', 0);
if ($excludeExisting) {
$query->whereNotIn('vehicle_scores.vehicle', function ($q) {
$q->select('vehicle')->from('car_show_winners');
});
}
if ($startYear !== null) $query->where('vehicles.year', '>=', $startYear);
if ($endYear !== null) $query->where('vehicles.year', '<=', $endYear);
$maxScore = (clone $query)
->groupBy('vehicles.id')
->selectRaw('sum(vehicle_scores.overall_score) as totalscore')
->orderBy('totalscore', 'desc')
->value('totalscore');
if ($maxScore) {
$winners = $query->selectRaw('vehicles.id as vehicle_id, sum(vehicle_scores.overall_score) as totalscore')
->groupBy('vehicles.id')
->having('totalscore', '=', $maxScore)
->get();
foreach ($winners as $winner) {
CarShowWinner::updateOrCreate([
'category' => $categoryId,
'place' => $place,
'vehicle' => $winner->vehicle_id
], [
// Added totalscore here
'total_score' => $winner->totalscore
]);
}
}
}
private function recordPeoplesChoiceWinners($categoryId, $place)
{
$maxVotes = PeoplesChoice::join('vehicles', 'peoples_choice.vehicle', '=', 'vehicles.id')
->where('vehicles.doNotJudge', 0)
->whereNotIn('peoples_choice.vehicle', function ($q) {
$q->select('vehicle')->from('car_show_winners');
})
->groupBy('peoples_choice.vehicle')
->selectRaw('sum(pc_count) as totalvotes')
->orderBy('totalvotes', 'desc')
->value('totalvotes');
if ($maxVotes) {
$winners = PeoplesChoice::join('vehicles', 'peoples_choice.vehicle', '=', 'vehicles.id')
->selectRaw('peoples_choice.vehicle as vehicle_id, sum(pc_count) as totalvotes')
->where('vehicles.doNotJudge', 0)
->whereNotIn('peoples_choice.vehicle', function ($q) {
$q->select('vehicle')->from('car_show_winners');
})
->groupBy('peoples_choice.vehicle')
->having('totalvotes', '=', $maxVotes)
->get();
foreach ($winners as $winner) {
CarShowWinner::create([
'category' => $categoryId,
'place' => $place,
'vehicle' => $winner->vehicle_id,
// Added totalvotes here
'total_score' => $winner->totalvotes
]);
}
}
}
}
-1
View File
@@ -14,7 +14,6 @@ class Kernel extends ConsoleKernel
*/ */
protected $commands = [ protected $commands = [
Commands\TabulateWinners::class, Commands\TabulateWinners::class,
Commands\TabulateWinnersNew::class,
]; ];
/** /**
-5
View File
@@ -161,11 +161,6 @@
Tabulate Show Winners Tabulate Show Winners
</a> </a>
</li> </li>
<li>
<a href="/tabulateshowwinnersnew">
Tabulate Show Winners New
</a>
</li>
</ul> </ul>
</li> </li>
<li class="dropdown"> <li class="dropdown">
-4
View File
@@ -63,8 +63,4 @@ Route::group(['middleware' => 'auth'], function() {
Artisan::call('carshow:tabulatewinners'); Artisan::call('carshow:tabulatewinners');
return redirect('showwinners'); return redirect('showwinners');
}); });
Route::get('tabulateshowwinnersnew', function() {
Artisan::call('carshow:tabulatewinnersnew');
return redirect('showwinners');
});
}); });