<?php

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

class CreateFaqs extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('faqs', function (Blueprint $table) {
            // General
            $table->bigIncrements('id');
            $table->unsignedBigInteger('backend_user_id')->nullable();
            $table->unsignedBigInteger('faq_category_id')->nullable();
            $table->unsignedInteger('views')->default(0);
            $table->nullableTimestamps();

            $table->foreign('backend_user_id')->references('id')
                ->on('backend_users')->onDelete('SET NULL')->onUpdate('CASCADE');
            $table->foreign('faq_category_id')->references('id')
                ->on('faq_categories')->onDelete('SET NULL')->onUpdate('CASCADE');
        });
    }

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

}
