code/database/migrations/2015_11_24_011701_create_comments_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCommentsTable extends Migration
{
public function up()
{
Schema::create('comments', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('title')->nullable();
$table->text('body');
$table->integer('parent_id')->nullable();
$table->integer('lft')->nullable();
$table->integer('rgt')->nullable();
$table->integer('depth')->nullable();
$table->morphs('commentable');
$table->string('user_id');
$table->index('commentable_id');
$table->index('commentable_type');
$table->foreign('user_id')->references('id')->on('users');
});
}
public function down()
{
Schema::drop('comments');
}
}