2023-12-19 09:23:16 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
2023-12-19 09:42:56 -08:00
|
|
|
use \App\Helpers\Helper;
|
|
|
|
use \App\Models\Setting;
|
|
|
|
use \App\Models\User;
|
2023-12-19 09:23:16 -08:00
|
|
|
|
|
|
|
class FixLanguageDirs extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
2023-12-19 09:42:56 -08:00
|
|
|
/**
|
|
|
|
* Update the settings table
|
|
|
|
*/
|
|
|
|
$settings = Setting::getSettings();
|
2023-12-19 11:00:11 -08:00
|
|
|
if (($settings) && ($settings->locale != '')) {
|
2023-12-19 09:42:56 -08:00
|
|
|
DB::table('settings')->update(['locale' => Helper::mapLegacyLocale($settings->locale)]);
|
2023-12-19 09:23:16 -08:00
|
|
|
}
|
|
|
|
|
2023-12-19 09:42:56 -08:00
|
|
|
/**
|
|
|
|
* 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)]);
|
|
|
|
}
|
2023-12-19 09:23:16 -08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|