]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/TournamentController.php
tournament settings
[alttp.git] / app / Http / Controllers / TournamentController.php
index fd9aab35d79e91bae3be78889d49885ea740df6c..e2fbe941a31b6b2b705b1e35c69724e495351191 100644 (file)
@@ -44,6 +44,38 @@ class TournamentController extends Controller
                return $tournament->toJson();
        }
 
+       public function discord(Request $request, Tournament $tournament) {
+               $this->authorize('update', $tournament);
+               $validatedData = $request->validate([
+                       'guild_id' => 'string|nullable',
+               ]);
+               if (array_key_exists('guild_id', $validatedData)) {
+                       $tournament->discord = $validatedData['guild_id'];
+               }
+               $tournament->save();
+               if ($tournament->wasChanged()) {
+                       TournamentChanged::dispatch($tournament);
+                       Protocol::tournamentDiscord($tournament, $request->user());
+               }
+               return $tournament->toJson();
+       }
+
+       public function discordSettings(Request $request, Tournament $tournament) {
+               $this->authorize('update', $tournament);
+               $validatedData = $request->validate([
+                       'round_template' => 'string|nullable',
+               ]);
+               if (array_key_exists('round_template', $validatedData)) {
+                       $tournament->discord_round_template = $validatedData['round_template'];
+               }
+               $tournament->save();
+               if ($tournament->wasChanged()) {
+                       TournamentChanged::dispatch($tournament);
+                       Protocol::tournamentDiscordSettings($tournament, $request->user());
+               }
+               return $tournament->toJson();
+       }
+
        public function open(Request $request, Tournament $tournament) {
                $this->authorize('update', $tournament);
                $tournament->accept_applications = true;