<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        $paypalSettings = [
            [
                'key' => 'paypal_mode',
                'value' => config('services.paypal.mode'),
                'type' => 'string',
                'group' => 'payment',
                'description' => 'PayPal mode (sandbox or live)',
            ],
            [
                'key' => 'paypal_email',
                'value' => config('services.paypal.email'),
                'type' => 'string',
                'group' => 'payment',
                'description' => 'PayPal email address for receiving payments',
            ],
        ];

        foreach ($paypalSettings as $setting) {
            $setting['created_at'] = now();
            $setting['updated_at'] = now();

            DB::table('settings')->insertOrIgnore($setting);
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        DB::table('settings')
            ->whereIn('key', ['paypal_mode', 'paypal_email'])
            ->delete();
    }
};
