<?php

use App\Enums\OrderType;
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::table('orders', function (Blueprint $table) {

            $table->unsignedInteger('profit_center_id')->nullable()->after('id');
            $table->string('contactName')->nullable()->after('supplier_id');
            $table->text('note')->nullable()->after('contactName');
            $table->enum('orderType', OrderType::getValues())->default(
                OrderType::daily)->after('note');
            $table->date('deliveryDate')->nullable()->after('orderType');
            $table->unsignedInteger('deliveryAddressId')->nullable()->after('deliveryDate');
            $table->string('deliveryAddress')->nullable()->after('deliveryAddressId');
            $table->json('productSelected')->nullable()->after('deliveryAddress');
            $table->unsignedInteger('supplierOrderNumber')->nullable()->after('confirmed');
            $table->float('sumPrice')->nullable()->after('humanId');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('orders', function (Blueprint $table) {
            $table->dropColumn('profit_center_id');
            $table->dropColumn('contactName');
            $table->dropColumn('note');
            $table->dropColumn('orderType');
            $table->dropColumn('deliveryDate');
            $table->dropColumn('deliveryAddress');
            $table->dropColumn('productSelected');
            $table->dropColumn('supplierOrderNumber');
            $table->dropColumn('sumPrice');

        });
    }
};
