<?php

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

class CreateBanksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('banks', function (Blueprint $table) {
            $table->id();
            $table->foreignId('company_id')->unsigned();
            $table->string('reference')->nullable();
            $table->string('bank_name');
            $table->string('holder_name');
            $table->string('account_no');
            $table->string('bank_branch')->nullable();
            $table->string('swift')->nullable();
            $table->string('snap')->nullable();
            $table->integer('type')->default(BankAccountType::EXTERNAL);
            $table->integer('default')->default(false);
            $table->integer('status')->default(ApprovalStatus::APPROVED);
            $table->foreignId('country_id')->unsigned();
            $table->softDeletes();
            $table->timestamps();

            $table->foreign('country_id')->references('id')->on('countries');
            $table->foreign('company_id')->references('id')->on('companies');
        });
    }

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