<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSubtasksTable extends Migration
{

    public $set_schema_table = 'subtasks';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

//        protected $fillable = array('description','deadline','assigned_user_id','user_id','status');

        //
        Schema::create($this->set_schema_table, function ($table) {
            $table->increments('id');
            $table->string('title')->nullable();
            $table->text('description')->nullable();
            $table->date('deadline')->nullable();
            $table->integer('assigned_id')->nullable()->unsigned();
            $table->integer('user_id')->nullable()->unsigned();
            $table->integer('status_id')->nullable()->unsigned();
            $table->integer('task_id')->nullable()->unsigned();


            $table->foreign('assigned_id')->references('id')->on('users')->onDelete('set null');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
            $table->foreign('status_id')->references('id')->on('status')->onDelete('set null');
            $table->foreign('task_id')->references('id')->on('tasks')->onDelete('set null');

            $table->timestamps();

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop($this->set_schema_table);

    }
}
