<?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('shipping_settings', function (Blueprint $table) {
            $table->id();
            $table->enum('shipping_type', ['free', 'flat', 'per_governorate'])->default('flat');
            $table->decimal('flat_rate', 10, 2)->default(0);
            $table->json('governorate_rates')->nullable();
            $table->timestamps();
        });

        \App\Models\ShippingSetting::create([
            'shipping_type' => 'flat',
            'flat_rate' => 50,
            'governorate_rates' => null,
        ]);
    }

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