<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Mehrab\Service\Models\Question_Answer_Service;

class CreateQuestionAnswerServiceTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('question_answer_service', function (Blueprint $table) {
            $table->id();

            $table->foreignId('service_id')
                ->nullable()
                ->constrained('services','id')
                ->onDelete('CASCADE');

            $table->foreignId('parent_id')
                ->nullable()
                ->constrained('question_answer_service','id')
                ->onDelete('CASCADE');


            $table->longText('content');
            $table->float('priority')->nullable();
            $table->integer('price')->default(0);
            $table->enum('type',Question_Answer_Service::$types)->nullable()->default(null);
        });
    }

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