diff --git a/database/migrations/2023_12_19_081112_fix_language_dirs.php b/database/migrations/2023_12_19_081112_fix_language_dirs.php index 0f2e1fe3b9..67090a34a3 100644 --- a/database/migrations/2023_12_19_081112_fix_language_dirs.php +++ b/database/migrations/2023_12_19_081112_fix_language_dirs.php @@ -3,6 +3,9 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; +use \App\Helpers\Helper; +use \App\Models\Setting; +use \App\Models\User; class FixLanguageDirs extends Migration { @@ -13,15 +16,22 @@ class FixLanguageDirs extends Migration */ public function up() { - // Pull the autoglossonym array from the localizations translation file - foreach (trans('localizations.languages') as $abbr) { - $select .= ' '; + /** + * Update the settings table + */ + $settings = Setting::getSettings(); + if ($settings->locale != '') { + DB::table('settings')->update(['locale' => Helper::mapLegacyLocale($settings->locale)]); } - Schema::table('models', function (Blueprint $table) { - $table->integer('min_amt')->nullable()->change(); - }); - + /** + * Update the users table + */ + $users = User::whereNotNull('locale')->whereNull('deleted_at')->get(); + // Skip the model in case the validation rules have changed + foreach ($users as $user) { + DB::table('users')->where('id', $user->id)->update(['locale' => Helper::mapLegacyLocale($user->locale)]); + } }