<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        $settings = [
            [
                'setting_key' => 'razorpay_enabled',
                'setting_value' => 'true',
                'setting_type' => 'boolean',
                'description' => 'Enable/Disable Razorpay Payment Gateway',
            ],
            [
                'setting_key' => 'razorpay_key',
                'setting_value' => '',
                'setting_type' => 'string',
                'description' => 'Razorpay API Key',
            ],
            [
                'setting_key' => 'razorpay_secret',
                'setting_value' => '',
                'setting_type' => 'string',
                'description' => 'Razorpay API Secret',
            ],
            [
                'setting_key' => 'paypal_enabled',
                'setting_value' => 'false',
                'setting_type' => 'boolean',
                'description' => 'Enable/Disable PayPal Payment Gateway',
            ],
            [
                'setting_key' => 'paypal_client_id',
                'setting_value' => '',
                'setting_type' => 'string',
                'description' => 'PayPal Client ID',
            ],
            [
                'setting_key' => 'paypal_secret',
                'setting_value' => '',
                'setting_type' => 'string',
                'description' => 'PayPal Secret',
            ],
            [
                'setting_key' => 'manual_payment_enabled',
                'setting_value' => 'true',
                'setting_type' => 'boolean',
                'description' => 'Enable/Disable Manual Payment (Bank Transfer)',
            ],
            [
                'setting_key' => 'manual_payment_instructions',
                'setting_value' => "Bank Name: Example Bank\nAccount Name: The Mini Port\nAccount Number: 1234567890\nIFSC: EXMP0001234",
                'setting_type' => 'string',
                'description' => 'Instructions for Manual Payment',
            ],
        ];

        foreach ($settings as $setting) {
            PromotionSetting::upsert(
                $setting,
                ['setting_key'],
                ['setting_value', 'setting_type', 'description']
            );
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Optional: Remove settings
    }
};
