<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();
            $table->string('order_id')->unique(); // Example: KNT-25-00000001
            $table->string('mark_no'); // linked to mark_lists.mark_no
            $table->string('description')->nullable();
            $table->string('origin')->nullable();
            $table->string('destination')->nullable();
            $table->integer('ctn')->nullable();
            $table->integer('qty')->nullable();
            $table->integer('ttl_qty')->nullable();
            $table->string('unit')->nullable();
            $table->decimal('price', 10, 2)->nullable();
            $table->decimal('ttl_amount', 10, 2)->nullable();
            $table->decimal('cbm', 10, 3)->nullable();
            $table->decimal('ttl_cbm', 10, 3)->nullable();
            $table->decimal('kg', 10, 3)->nullable();
            $table->decimal('ttl_kg', 10, 3)->nullable();
            $table->string('shop_no')->nullable();
            $table->string('status')->default('in_transit'); // in_transit, dispatched, delivered
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('orders');
    }
};
