]> git.localhorst.tv Git - alttp.git/blob - app/Console/Commands/RecalculateTournamentPlacements.php
sync ladder schedule
[alttp.git] / app / Console / Commands / RecalculateTournamentPlacements.php
1 <?php
2
3 namespace App\Console\Commands;
4
5 use App\Models\Tournament;
6 use Illuminate\Console\Command;
7
8 class RecalculateTournamentPlacements extends Command
9 {
10         /**
11          * The name and signature of the console command.
12          *
13          * @var string
14          */
15         protected $signature = 'tournament:recalc {tournament}';
16
17         /**
18          * The console command description.
19          *
20          * @var string
21          */
22         protected $description = 'Recalculate tournament placements';
23
24         /**
25          * Execute the console command.
26          *
27          * @return int
28          */
29         public function handle()
30         {
31                 $tournament = Tournament::findOrFail($this->argument('tournament'));
32
33                 foreach ($tournament->rounds as $round) {
34                         $round->updatePlacement();
35                 }
36                 $tournament->updatePlacement();
37
38                 return 0;
39         }
40 }