]> git.localhorst.tv Git - alttp.git/commitdiff
tournament locale
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 2 May 2022 17:15:29 +0000 (19:15 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 2 May 2022 17:15:29 +0000 (19:15 +0200)
app/DiscordBotCommands/BaseCommand.php
database/migrations/2022_05_02_165756_tournament_locale.php [new file with mode: 0644]

index eb3a012561c9bdc8f6e6faae8145797fff51e3be..b043af2ecd7f06da98e242381ebf3ceda3f7361f 100644 (file)
@@ -30,6 +30,9 @@ abstract class BaseCommand {
        protected function __construct(Discord $discord, DiscordBotCommand $cmd) {
                $this->discord = $discord;
                $this->command = $cmd;
+               if ($cmd->tournament && $cmd->tournament->locale) {
+                       App::setLocale($cmd->tournament->locale);
+               }
        }
 
        protected function fetchGuild() {
@@ -40,7 +43,7 @@ abstract class BaseCommand {
                        ->fetch($this->command->tournament->discord)
                        ->then(function (Guild $guild) {
                                $this->guild = $guild;
-                               if ($guild->preferred_locale) {
+                               if ($guild->preferred_locale && !($this->command->tournament && $this->command->tournament->locale)) {
                                        App::setLocale($guild->preferred_locale);
                                }
                                return $guild;
diff --git a/database/migrations/2022_05_02_165756_tournament_locale.php b/database/migrations/2022_05_02_165756_tournament_locale.php
new file mode 100644 (file)
index 0000000..a3ea5cf
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::table('tournaments', function(Blueprint $table) {
+                       $table->string('locale')->nullable()->default(null);
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::table('tournaments', function(Blueprint $table) {
+                       $table->dropColumn('locale');
+               });
+       }
+};