<?php

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

class CreateHotelTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('hotels', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('hotel_id')->nullable();
            $table->unsignedBigInteger('category_id')->nullable();
            $table->string('distance_from_haram', 10)->nullable();
            $table->string('floors_number', 5)->nullable();
            $table->string('rooms_number', 5)->nullable();
            $table->string('beds_number', 5)->nullable();
            $table->string('phone')->nullable();
            $table->text('map')->nullable();
            $table->bigInteger('visit_counts')->nullable();



            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
            $table->foreign('hotel_id')->references('id')->on('hotels')->onDelete('cascade');

            $table->index(['category_id', 'hotel_id']);

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

            // Set engine to InnoDB it's useful in join and constraint
            $table->engine = 'InnoDB';
        });
    }

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