From: Daniel Karbach Date: Mon, 2 May 2022 17:15:29 +0000 (+0200) Subject: tournament locale X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=e3880b3664a3916242a8a774a188686dd5c5297f;p=alttp.git tournament locale --- diff --git a/app/DiscordBotCommands/BaseCommand.php b/app/DiscordBotCommands/BaseCommand.php index eb3a012..b043af2 100644 --- a/app/DiscordBotCommands/BaseCommand.php +++ b/app/DiscordBotCommands/BaseCommand.php @@ -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 index 0000000..a3ea5cf --- /dev/null +++ b/database/migrations/2022_05_02_165756_tournament_locale.php @@ -0,0 +1,32 @@ +string('locale')->nullable()->default(null); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tournaments', function(Blueprint $table) { + $table->dropColumn('locale'); + }); + } +};