<?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('shipping_methods', function (Blueprint $table) {
            // Pricing type: flat (fixed cost) or weight_based (base + per_kg)
            $table->string('pricing_type')->default('flat')->after('zone');

            // For weight_based: base fee + per kg charge
            $table->decimal('base_cost', 10, 2)->nullable()->after('pricing_type');
            $table->decimal('per_kg_rate', 10, 2)->nullable()->after('base_cost');

            // Optional weight limit in grams (null = no limit)
            $table->unsignedInteger('max_weight_g')->nullable()->after('per_kg_rate');

            // Estimated delivery time in working days
            $table->unsignedTinyInteger('estimated_days')->nullable()->after('max_weight_g');
        });
    }

    public function down(): void
    {
        Schema::table('shipping_methods', function (Blueprint $table) {
            $table->dropColumn([
                'pricing_type',
                'base_cost',
                'per_kg_rate',
                'max_weight_g',
                'estimated_days',
            ]);
        });
    }
};
