<?php

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

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


            $table->bigInteger('booking_id')->index();
            $table->integer('travel_program_id')->index();
            $table->integer('travel_class_id')->nullable()->index();


            $table->unsignedInteger('draft_item_id')->nullable()->index();
            $table->integer('draft_type_id')->nullable()->index();

            $table->date('request_date')->nullable();

            $table->tinyInteger('days_start')->unsigned()->nullable();
            $table->tinyInteger('days_duration')->unsigned()->nullable();

            $table->date('start_date')->nullable();
            $table->date('end_date')->nullable();

            $table->text('service')->nullable();
            $table->decimal('price_adult', 8, 2)->nullable();
            $table->tinyInteger('adult')->unsigned()->nullable();
            $table->decimal('price_children', 8, 2)->nullable();
            $table->tinyInteger('children')->unsigned()->nullable();

            $table->decimal('price', 8, 2)->nullable();

            $table->tinyInteger('pos')->unsigned()->nullable();
            $table->boolean('in_pdf')->default(true);
            $table->boolean('status')->default(false);

            $table->boolean('comfort')->default(false);


            $table->timestamps();

            $table->foreign('booking_id')
                ->references('id')
                ->on('booking');

            $table->foreign('draft_item_id')
                ->references('id')
                ->on('draft_items');

            $table->foreign('draft_type_id')
                ->references('id')
                ->on('draft_types');

        });
    }

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