<?php

use App\Classes\ValueObjects\Constants\ApprovalStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateBookingsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('bookings', function (Blueprint $table) {
            $table->id();
            $table->foreignId('company_id')->unsigned();
            $table->string('marking')->unique();
            $table->foreignId('service_id')->unsigned();
            $table->foreignId('bank_id')->unsigned();
            $table->decimal('fix_amount', 20, 5);
            $table->foreignId('fix_currency_id')->unsigned();
            $table->foreignId('convertible_currency_id')->unsigned();
            $table->foreignId('conversion_currency_id')->unsigned();
            $table->integer('status')->default(ApprovalStatus::APPROVED);
            $table->softDeletes();
            $table->timestamps();

            $table->foreign('company_id')->references('id')->on('companies');
            $table->foreign('service_id')->references('id')->on('service_types');
            $table->foreign('bank_id')->references('id')->on('banks');
            $table->foreign('fix_currency_id')->references('id')->on('currencies');
            $table->foreign('convertible_currency_id')->references('id')->on('currencies');
            $table->foreign('conversion_currency_id')->references('id')->on('currencies');
        });
    }

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