FEATURE: add module id into contents table
This commit is contained in:
@@ -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
|
||||
]);
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user