<?php

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

class CreateDraftItemsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('draft_items', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('draft_id')->index();
            $table->unsignedInteger('draft_type_id')->nullable()->index();

            $table->tinyInteger('days_start')->unsigned()->nullable();
            $table->tinyInteger('days_duration')->unsigned()->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('active')->default(true);

            $table->timestamps();

            $table->foreign('draft_id')
                ->references('id')
                ->on('drafts');

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

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



