FEATURE: add functionality for creating new widget.

This commit adds functionality for creating widget of whatever type. Controller calls widget admin handler, which renders and handles input form.
This commit is contained in:
Michal Kváček
2016-02-15 12:19:54 +01:00
parent 043c842aef
commit ccc2d918c9
8 changed files with 289 additions and 0 deletions
@@ -0,0 +1,78 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIdToWidgetTypes extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// drop foreign key from widgets table
try {
Schema::table('widgets', function (Blueprint $table) {
$table->dropForeign('fk_widget_widget_type1');
});
} catch (Exception $e) {
Schema::table('widgets', function (Blueprint $table) {
$table->dropForeign('widgets_widget_type_handler_foreign');
});
}
// try to drop primary key (should be on handler column)
Schema::table('widget_types', function (Blueprint $table) {
$table->dropIndex('PRIMARY');
});
// add new column "id" with autoincrement and make handler unique, not primary
Schema::table('widget_types', function (Blueprint $table) {
$table->integer('id', true)
->first();
$table->string('handler')
->unique()
->change();
});
// create foreign constraint active again
Schema::table('widgets', function (Blueprint $table) {
$table->foreign('widget_type_handler')
->references('handler')
->on('widget_types')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('widgets', function (Blueprint $table) {
$table->dropForeign('widgets_widget_type_handler_foreign');
});
Schema::table('widget_types', function (Blueprint $table) {
$table->dropColumn('id');
$table->dropIndex('widget_types_handler_unique');
$table->string('handler')
->primary()
->change();
});
// create foreign constraint active again
Schema::table('widgets', function (Blueprint $table) {
$table->foreign('widget_type_handler')
->references('handler')
->on('widget_types')
->onDelete('cascade');
});
}
}