FEATURE: make settings translatable

This commit is contained in:
Michal Kváček
2016-07-23 21:47:20 +02:00
parent b89941b909
commit ab3d8eab41
11 changed files with 150 additions and 47 deletions
@@ -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');
});
}
}