<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\Setting;

return new class extends Migration
{
    public function up(): void
    {
        // Update or Create MOQ Settings
        $settings = [
            // Keys used in Views (Home, Product Card)
            [
                'key' => 'min_moq',
                'value' => '10',
                'group' => 'general',
                'type' => 'text',
                'label' => 'Min MOQ',
            ],
            [
                'key' => 'max_moq',
                'value' => '150',
                'group' => 'general',
                'type' => 'text',
                'label' => 'Max MOQ',
            ],
            // Keys used in Registration Controller
            [
                'key' => 'registration_moq_min',
                'value' => '10',
                'group' => 'general',
                'type' => 'text',
                'label' => 'Registration Min MOQ',
            ],
            [
                'key' => 'registration_moq_max',
                'value' => '150',
                'group' => 'general',
                'type' => 'text',
                'label' => 'Registration Max MOQ',
            ],
        ];

        foreach ($settings as $setting) {
            Setting::updateOrCreate(
                ['key' => $setting['key']],
                $setting
            );
        }
    }

    public function down(): void
    {
        //
    }
};
