]> git.localhorst.tv Git - alttp.git/blobdiff - app/Console/Commands/LockRound.php
lock rounds
[alttp.git] / app / Console / Commands / LockRound.php
diff --git a/app/Console/Commands/LockRound.php b/app/Console/Commands/LockRound.php
new file mode 100644 (file)
index 0000000..f0f81c1
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Events\RoundChanged;
+use App\Models\Protocol;
+use App\Models\Round;
+use Illuminate\Console\Command;
+
+class LockRound extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'round:lock {round}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Lock the round';
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+               $round = Round::findOrFail($this->argument('round'));
+
+               if ($round->locked) {
+                       $this->line('already locked');
+                       return 0;
+               }
+
+               $round->locked = true;
+               $round->save();
+
+               Protocol::roundLocked(
+                       $round->tournament,
+                       $round,
+               );
+
+               RoundChanged::dispatch($round);
+
+        return 0;
+    }
+}