<?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::table('products', function (Blueprint $table) {
            // Satuan besar (karton/dus)
            $table->string('bulk_unit')->default('Karton')->after('price');
            // Harga satuan besar
            $table->decimal('bulk_price', 15, 2)->nullable()->after('bulk_unit');
            // Isi per satuan besar (misal: 40 pcs per karton)
            $table->integer('bulk_quantity')->default(1)->after('bulk_price');
            // Harga eceran (per pcs/kg/liter)
            $table->decimal('retail_price', 15, 2)->nullable()->after('bulk_quantity');
            // Satuan eceran
            $table->string('retail_unit')->default('pcs')->after('retail_price');
        });
    }

    public function down(): void
    {
        Schema::table('products', function (Blueprint $table) {
            $table->dropColumn([
                'bulk_unit',
                'bulk_price',
                'bulk_quantity',
                'retail_price',
                'retail_unit'
            ]);
        });
    }
};
