40 lines
919 B
PHP
40 lines
919 B
PHP
<?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');
|
|
}
|
|
}
|
|
}
|