Correct error in doubler class. Add artisan command to sync doublers.
This commit is contained in:
parent
f3591e9a08
commit
f3013670a3
|
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -69,6 +69,7 @@ class Doubler extends Model
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'accepted_entry' => $acceptedEntryId,
|
'accepted_entry' => $acceptedEntryId,
|
||||||
|
'entry_count' => $student->entriesForEvent($eventId)->count(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue