<?php

namespace Database\Seeders;

use App\Models\Setting;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class SettingSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        foreach ([
            ['group_key' => 'pricing', 'key' => 'pricing_per_page_bw', 'value' => '3', 'type' => 'number', 'label' => 'Black and white page rate'],
            ['group_key' => 'pricing', 'key' => 'pricing_color_multiplier', 'value' => '2', 'type' => 'number', 'label' => 'Color print multiplier'],
            ['group_key' => 'pricing', 'key' => 'pricing_double_sided_discount', 'value' => '0.9', 'type' => 'number', 'label' => 'Double sided discount factor'],
            ['group_key' => 'pricing', 'key' => 'pricing_binding_charge', 'value' => '25', 'type' => 'number', 'label' => 'Binding charge'],
            ['group_key' => 'pricing', 'key' => 'pricing_lamination_charge', 'value' => '20', 'type' => 'number', 'label' => 'Lamination charge'],
            ['group_key' => 'pricing', 'key' => 'pricing_pvc_card_charge', 'value' => '90', 'type' => 'number', 'label' => 'PVC card charge'],
            ['group_key' => 'pricing', 'key' => 'pricing_delivery_charge', 'value' => '60', 'type' => 'number', 'label' => 'Delivery charge'],
            ['group_key' => 'pricing', 'key' => 'pricing_gst_percentage', 'value' => '18', 'type' => 'number', 'label' => 'GST percentage'],
            ['group_key' => 'documents', 'key' => 'documents_max_upload_kb', 'value' => '10240', 'type' => 'number', 'label' => 'Maximum upload size in KB'],
            ['group_key' => 'documents', 'key' => 'documents_auto_delete_days', 'value' => '30', 'type' => 'number', 'label' => 'Auto delete file retention'],
            ['group_key' => 'platform', 'key' => 'platform_name', 'value' => 'Print Cards', 'type' => 'string', 'label' => 'Platform name', 'is_public' => true],
            ['group_key' => 'platform', 'key' => 'platform_tagline', 'value' => 'ABHA, PAN, Aadhaar and government card printing with courier delivery', 'type' => 'string', 'label' => 'Homepage tagline', 'is_public' => true],
            ['group_key' => 'platform', 'key' => 'platform_support_phone', 'value' => '+91 98765 43210', 'type' => 'string', 'label' => 'Support phone', 'is_public' => true],
            ['group_key' => 'platform', 'key' => 'platform_support_email', 'value' => 'support@printcards.test', 'type' => 'string', 'label' => 'Support email', 'is_public' => true],
            ['group_key' => 'platform', 'key' => 'platform_whatsapp_number', 'value' => '919876543210', 'type' => 'string', 'label' => 'WhatsApp number', 'is_public' => true],
            ['group_key' => 'platform', 'key' => 'platform_faq_json', 'value' => json_encode([
                ['question' => 'Do you create government cards?', 'answer' => 'No. We only print files uploaded by the customer and do not alter official records.'],
                ['question' => 'Which file types are accepted?', 'answer' => 'PDF, JPG, JPEG, and PNG files are accepted with preview before upload.'],
                ['question' => 'How are orders delivered?', 'answer' => 'Orders can be shipped through India Post, Delhivery, or any courier partner configured by the admin.'],
            ]), 'type' => 'json', 'label' => 'Homepage FAQs', 'is_public' => true],
            ['group_key' => 'platform', 'key' => 'platform_testimonials_json', 'value' => json_encode([
                ['name' => 'Seema Sharma', 'location' => 'Shimla', 'message' => 'Fast PVC card delivery and clear status updates throughout the process.'],
                ['name' => 'Rohit Kumar', 'location' => 'Hamirpur', 'message' => 'Uploading PAN and ABHA files was simple, and the courier tracking worked well.'],
            ]), 'type' => 'json', 'label' => 'Homepage testimonials', 'is_public' => true],
            ['group_key' => 'payment', 'key' => 'payment_gateway_enabled', 'value' => 'true', 'type' => 'boolean', 'label' => 'Enable payment gateway'],
            ['group_key' => 'payment', 'key' => 'payment_demo_mode', 'value' => 'true', 'type' => 'boolean', 'label' => 'Enable payment demo mode'],
            ['group_key' => 'payment', 'key' => 'payment_default_provider', 'value' => 'razorpay', 'type' => 'string', 'label' => 'Default provider'],
            ['group_key' => 'payment', 'key' => 'payment_razorpay_key', 'value' => 'rzp_test_demo_key', 'type' => 'string', 'label' => 'Razorpay key'],
            ['group_key' => 'payment', 'key' => 'payment_razorpay_secret', 'value' => 'demo_razorpay_secret', 'type' => 'string', 'label' => 'Razorpay secret'],
            ['group_key' => 'payment', 'key' => 'payment_payu_key', 'value' => 'payu_demo_key', 'type' => 'string', 'label' => 'PayU merchant key'],
            ['group_key' => 'payment', 'key' => 'payment_payu_salt', 'value' => 'demo_payu_salt', 'type' => 'string', 'label' => 'PayU salt'],
            ['group_key' => 'courier', 'key' => 'courier_default_partner', 'value' => 'Delhivery', 'type' => 'string', 'label' => 'Default courier partner'],
            ['group_key' => 'courier', 'key' => 'courier_tracking_base_url', 'value' => 'https://www.delhivery.com/track-v2/package/', 'type' => 'string', 'label' => 'Tracking base URL'],
            ['group_key' => 'courier', 'key' => 'courier_secondary_partner', 'value' => 'India Post', 'type' => 'string', 'label' => 'Secondary courier partner'],
        ] as $setting) {
            Setting::query()->updateOrCreate(
                ['key' => $setting['key']],
                $setting
            );
        }
    }
}
