<?php

use App\Enums\ApprovalType;
use App\Enums\Finance;
use App\Enums\ImporterName;
use App\Enums\Port;
use App\Enums\Product;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('approvals', function (Blueprint $table) {
            $table->id();
            $table->string('number')->unique()->nullable();
            $table->enum('port_name', array_column(Port::cases(), 'value'))->default(Port::HASSIA->value);
            $table->date('date');
            $table->date('end_date');
            $table->string('source_name')->nullable();
            $table->string('source_factory')->nullable();
            $table->enum('importer_name', array_column(ImporterName::cases(), 'value'))->default(ImporterName::ALMATININDUSTRIAL->value);
            $table->enum('approval_type', array_column(ApprovalType::cases(), 'value'))->default(ApprovalType::COMMERCIAL->value);
            $table->enum('goods_type', array_column(Product::cases(), 'value'))->default(Product::POLYETHYLENE->value);
            $table->enum('financial_type', array_column(Finance::cases(), 'value'))->default(Finance::FADEL->value);
            $table->decimal('qty', 20, 5)->nullable();
            $table->decimal('value_usd', 20, 5)->nullable();
            $table->decimal('value_syp', 20, 5)->nullable();
            $table->timestamps();
        });
    }

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