FEATURE: make settings translatable
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AddLanguageIntoSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::raw("ALTER TABLE `settings`
|
||||
CHANGE `language` `language` varchar(8) COLLATE 'utf8_general_ci' NULL AFTER `id`,
|
||||
CHANGE `key` `key` varchar(64) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'User readable key for accessing value of this config. Config will be available under this key also in views.' AFTER `language`,
|
||||
CHANGE `value` `value` text COLLATE 'utf8_general_ci' NOT NULL COMMENT 'Value of config.' AFTER `key`,
|
||||
COLLATE 'utf8_general_ci';");
|
||||
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->string('language', 8)
|
||||
->after('id')
|
||||
->nullable(true)
|
||||
->default(null);
|
||||
|
||||
$table->dropUnique('settings_key_unique');
|
||||
$table->unique(['key', 'language']);
|
||||
|
||||
$table->foreign('language')
|
||||
->references('code')
|
||||
->on('languages')
|
||||
->onDelete('set null')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->dropForeign('settings_language_foreign');
|
||||
$table->dropColumn('language');
|
||||
$table->dropUnique('settings_key_language_unique');
|
||||
$table->unique('key');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user