<?php

namespace Database\Seeders;

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

class FixSettingsGroupsSeeder extends Seeder
{
    public function run()
    {
        $mappings = [
            'payment' => [
                'payment_gateway_mode', 'razorpay_key', 'razorpay_secret', 'razorpay_enabled',
                'paypal_client_id', 'paypal_secret', 'paypal_enabled', 'paypal_mode',
                'manual_payment_enabled', 'manual_payment_instructions', 'demo_mode_enabled',
                'gst_percentage', 'stripe_key', 'stripe_secret'
            ],
            'home' => [
                'home_stat_products_count', 'home_stat_products_label', 'home_stat_suppliers_count',
                'home_stat_suppliers_label', 'home_stat_buyers_count', 'home_stat_buyers_label',
                'home_stat_support_count', 'home_stat_support_label', 'home_show_trending'
            ],
            'social' => [
                'social_facebook', 'social_twitter', 'social_instagram', 'social_linkedin', 'social_youtube'
            ],
            'seo' => [
                'seo_meta_title', 'seo_meta_description', 'seo_meta_keywords'
            ],
            'scripts' => [
                'scripts_header', 'scripts_footer'
            ],
            'features' => [
                'social_login_google_enabled', 'social_login_facebook_enabled', 'google_client_id',
                'google_client_secret', 'facebook_app_id', 'facebook_app_secret', 'whatsapp_enabled',
                'whatsapp_number', 'whatsapp_welcome_message', 'product_approval_required',
                'bulk_upload_enabled', 'help_page_enabled', 'newsletter_enabled', 'min_moq', 'max_moq'
            ],
            'help' => [
                'help_buyers_guide', 'help_sellers_guide', 'help_plans_guide',
                'help_notes_free', 'help_notes_moq', 'help_notes_kyc', 'help_notes_payment'
            ],
            'retention' => [
                'seller_retention_period', 'rfq_retention_period'
            ],
            'email' => [
                'mail_mailer', 'mail_host', 'mail_port', 'mail_username', 'mail_password',
                'mail_encryption', 'mail_from_address', 'mail_from_name'
            ]
        ];

        foreach ($mappings as $group => $keys) {
            Setting::whereIn('key', $keys)->update(['group' => $group]);
        }

        $this->command->info('Settings groups have been restored successfully.');
    }
}
