FEATURE: add support for categories into content save/edit

This commit is contained in:
Michal Kváček
2016-08-13 17:48:44 +02:00
parent 5aec27478a
commit 54e5927bb1
8 changed files with 108 additions and 7 deletions
@@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCategorySupport extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$platform = Schema::getConnection()
->getDoctrineSchemaManager()
->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('contents', function (Blueprint $table) {
$table->integer('category_id', false, true)
->comment('FK to table categories')
->after('module_handler')
->nullable(true)
->default(null);
});
Schema::table('contents', function (Blueprint $table) {
$table->foreign('category_id')
->references('id')
->on('categories')
->onDelete('set null')
->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$platform = Schema::getConnection()
->getDoctrineSchemaManager()
->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('contents', function (Blueprint $table) {
$table->dropForeign('contents_category_id_foreign');
$table->dropColumn('category_id');
});
}
}