Correct error in doubler class. Add artisan command to sync doublers.

This commit is contained in:
Matt Young 2025-06-22 23:38:35 -05:00
parent f3591e9a08
commit f3013670a3
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use App\Models\Doubler;
use App\Models\Event;
use Illuminate\Console\Command;
class SyncDoublers extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'doublers:sync {event? : Optional event ID}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update doublers table based on current entries';
/**
* Execute the console command.
*/
public function handle()
{
if ($eventId = $this->argument('event')) {
$event = Event::findOrFail($eventId);
Doubler::syncForEvent($event);
$this->info("Synced doublers for event {$event->name}");
} else {
Doubler::syncDoublers();
$this->info('Synced doublers for all events');
}
}
}

View File

@ -69,6 +69,7 @@ class Doubler extends Model
], ],
[ [
'accepted_entry' => $acceptedEntryId, 'accepted_entry' => $acceptedEntryId,
'entry_count' => $student->entriesForEvent($eventId)->count(),
] ]
); );
} }