FEATURE: add module id into contents table

This commit is contained in:
Michal Kváček
2016-03-09 21:55:27 +01:00
parent 464eaf8b17
commit bb7106d706
3 changed files with 48 additions and 0 deletions
@@ -47,6 +47,7 @@ class CopyTemplate extends Controller
'template_name' => $newName,
'name' => $newName,
'path' => $template->path,
'module_id' => $template->module_id,
'description' => $template->description,
'editable' => 1
]);
+1
View File
@@ -12,6 +12,7 @@ class Template extends Model
public $timestamps = true;
protected $fillable = [
'template_name',
'module_id',
'name',
'path',
'description',
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddModuleIdToTemplatesAgain extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('templates', function (Blueprint $table) {
$table->integer('module_id')
->after('id')
->nullable()
->default(null)
->comment('Template belongs to module specified with this ID.');
$table->index('module_id');
$table->foreign('module_id')
->references('id')
->on('modules')
->onDelete('cascade')
->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('templates', function (Blueprint $table) {
$table->dropForeign('templates_module_id_foreign');
$table->dropColumn('module_id');
});
}
}