<?php

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

class CreateUserKhatmsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_khatms', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id');
            $table->bigInteger('khatm_id');
            $table->bigInteger('khatm_pack_id');
            $table->bigInteger('start_quran_id');
            $table->string('start_quran_chapter');
            $table->Integer('start_quran_verse');
            $table->bigInteger('end_quran_id');
            $table->string('end_quran_chapter');
            $table->Integer('end_quran_Verse');
            $table->Integer('number_verses');
            $table->enum('status' , ['reading' , 'canceled' , 'end'])->default('reading');
            $table->foreign('user_id')->references('id')->on('users');
            $table->foreign('khatm_pack_id')->references('id')->on('khatm_packs');
            $table->foreign('khatm_id')->references('id')->on('khatms');
            $table->foreign('start_quran_id')->references('id')->on('quran');
            $table->foreign('end_quran_id')->references('id')->on('quran');
            $table->foreign('user_id')->references('id')->on('users');
            $table->timestamps();
        });
    }

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