<?php

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

class CreateConsultingEvaluateTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // *
        Schema::create('consulting_evaluates', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('consulting_request_id');
            $table->unsignedBigInteger('user_id');
//            $table->string('consulting_type', 30)->nullable();
//            $table->string('consulting_way', 30)->nullable();
//            $table->date('consulting_date')->nullable();
//            $table->time('consulting_time')->nullable();
//            $table->string('user_name', 100)->nullable();
//            $table->string('user_email', 100)->nullable();
//            $table->string('user_phone', 100)->nullable();
            $table->string('comment', 400);
            $table->tinyInteger('evaluate_average')->nullable();

            $table->boolean('status')->default(0);

            $table->foreign('consulting_request_id')->references('id')->on('consulting_requests')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

            $table->timestamps();
            $table->softDeletes();

            $table->index(['consulting_request_id', 'user_id'], 'cu');
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('evaluates');
    }
}
