FEATURE: add creating comments

This commit is contained in:
Michal Kváček
2016-09-05 12:50:04 +02:00
parent a33023a4aa
commit 9ce9f62a45
7 changed files with 192 additions and 26 deletions
@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateComments extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('comments', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('user_id')
->nullable(true)
->default(null)
->comment('When comment was inserted by logged user, save his ID here');
$table->integer('content_id');
$table->string('email');
$table->string('name');
$table->text('content');
$table->boolean('approved');
$table->foreign('content_id')
->references('id')
->on('contents')
->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('set null')
->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('comments');
}
}