]> git.localhorst.tv Git - alttp.git/blob - app/Console/Commands/LockTournament.php
sync ladder schedule
[alttp.git] / app / Console / Commands / LockTournament.php
1 <?php
2
3 namespace App\Console\Commands;
4
5 use App\Events\TournamentChanged;
6 use App\Models\Protocol;
7 use App\Models\Tournament;
8 use Illuminate\Console\Command;
9
10 class LockTournament extends Command
11 {
12         /**
13          * The name and signature of the console command.
14          *
15          * @var string
16          */
17         protected $signature = 'tournament:lock {tournament}';
18
19         /**
20          * The console command description.
21          *
22          * @var string
23          */
24         protected $description = 'Lock the tournament';
25
26         /**
27          * Execute the console command.
28          *
29          * @return int
30          */
31         public function handle()
32         {
33                 $tournament = Tournament::findOrFail($this->argument('tournament'));
34
35                 if ($tournament->locked) {
36                         $this->line('already locked');
37                         return 0;
38                 }
39
40                 $tournament->locked = true;
41                 $tournament->save();
42
43                 Protocol::tournamentLocked(
44                         $tournament,
45                 );
46
47                 TournamentChanged::dispatch($tournament);
48
49                 return 0;
50         }
51 }