<?php

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

class CreateCaixasTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('caixas', function (Blueprint $table) {
            $table->id();
            $table->integer('numerodacaixa')->nullable();
            $table->foreignId('reserva_id');
            $table->foreignId('usuario_id');
            $table->enum('estado',['Reservado','Anulado','Entrada','Arrumado','Aberto','Em aviso de eliminacao','Eliminado','Destruido','Em transito','Devolvido'])->default('Reservado')->nullable();
            $table->enum('etiqueta',['sim','nao'])->default('nao')->nullable();
            $table->foreign('usuario_id')->references('id')->on('users');
            $table->foreign('reserva_id')->references('id')->on('reservas')->onDelete('cascade');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('caixas', function(Blueprint $table)
        {
            $table->dropSoftDeletes();
        });

        Schema::dropIfExists('caixas');
    }
}
