<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Currency;

class CurrencySeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $currencies = [
            // --- 1. DEFAULT BASE CURRENCY ---
            [
                'name' => 'US Dollar',
                'code' => 'USD',
                'symbol' => '$',
                'exchange_rate' => 1.00000000,
                'is_active' => true,
                'is_default' => true,
            ],

            // --- ACTIVE CURRENCIES (For New Gateways) ---
            [
                'name' => 'Bangladeshi Taka',
                'code' => 'BDT',
                'symbol' => '৳',
                'exchange_rate' => 118.50000000,
                'is_active' => true,
                'is_default' => false,
            ],
            [
                'name' => 'Indian Rupee',
                'code' => 'INR',
                'symbol' => '₹',
                'exchange_rate' => 83.45000000,
                'is_active' => true, // Active for Razorpay
                'is_default' => false,
            ],
            [
                'name' => 'Russian Ruble',
                'code' => 'RUB',
                'symbol' => '₽',
                'exchange_rate' => 92.30000000,
                'is_active' => true, // Active for YooMoney
                'is_default' => false,
            ],
            [
                'name' => 'South African Rand',
                'code' => 'ZAR',
                'symbol' => 'R',
                'exchange_rate' => 18.90000000,
                'is_active' => true, // Active for Paystack/Flutterwave
                'is_default' => false,
            ],
            [
                'name' => 'Nigerian Naira',
                'code' => 'NGN',
                'symbol' => '₦',
                'exchange_rate' => 1450.00000000,
                'is_active' => true, // Active for Paystack/Flutterwave
                'is_default' => false,
            ],
            [
                'name' => 'Euro',
                'code' => 'EUR',
                'symbol' => '€',
                'exchange_rate' => 0.92000000,
                'is_active' => true,
                'is_default' => false,
            ],
            [
                'name' => 'UAE Dirham',
                'code' => 'AED',
                'symbol' => 'د.إ',
                'exchange_rate' => 3.67000000,
                'is_active' => true,
                'is_default' => false,
            ],
            [
                'name' => 'Tether (Crypto)',
                'code' => 'USDT',
                'symbol' => '₮',
                'exchange_rate' => 1.00050000,
                'is_active' => true,
                'is_default' => false,
            ],

            // --- INACTIVE / OPTIONAL CURRENCIES ---
            [
                'name' => 'British Pound',
                'code' => 'GBP',
                'symbol' => '£',
                'exchange_rate' => 0.79000000,
                'is_active' => false,
                'is_default' => false,
            ],
            [
                'name' => 'Ghanaian Cedi',
                'code' => 'GHS',
                'symbol' => 'GH₵',
                'exchange_rate' => 13.50000000,
                'is_active' => false,
                'is_default' => false,
            ],
            [
                'name' => 'Kenyan Shilling',
                'code' => 'KES',
                'symbol' => 'KSh',
                'exchange_rate' => 131.00000000,
                'is_active' => false,
                'is_default' => false,
            ],
            [
                'name' => 'Saudi Riyal',
                'code' => 'SAR',
                'symbol' => 'ر​​',
                'exchange_rate' => 3.75000000,
                'is_active' => false,
                'is_default' => false,
            ],
            [
                'name' => 'Japanese Yen',
                'code' => 'JPY',
                'symbol' => '¥',
                'exchange_rate' => 151.20000000,
                'is_active' => false,
                'is_default' => false,
            ],
            [
                'name' => 'Australian Dollar',
                'code' => 'AUD',
                'symbol' => 'A$',
                'exchange_rate' => 1.52000000,
                'is_active' => false,
                'is_default' => false,
            ]
        ];

        // Insert or Update the currencies in the database
        foreach ($currencies as $currency) {
            Currency::updateOrCreate(
                ['code' => $currency['code']], 
                $currency
            );
        }

        // Clear the cache so the frontend sees the new currencies instantly
        \Illuminate\Support\Facades\Cache::forget('active_currencies');
    }
}