<?php

namespace Database\Seeders;

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

class SettingSeeder extends Seeder
{
    public function run(): void
    {
        $defaults = [
            // General
            ['key' => 'site_name',       'value' => 'Blogs Portal',                       'type' => 'string',  'group' => 'general'],
            ['key' => 'site_tagline',    'value' => 'Premium Blog Network',               'type' => 'string',  'group' => 'general'],
            ['key' => 'contact_email',   'value' => 'hello@blogsportal.test',             'type' => 'string',  'group' => 'general'],
            ['key' => 'site_logo',       'value' => '',                                   'type' => 'file',    'group' => 'general'],
            ['key' => 'site_favicon',    'value' => '',                                   'type' => 'file',    'group' => 'general'],

            // SEO
            ['key' => 'meta_title',           'value' => 'Blogs Portal — Premium Blog Network',                                          'type' => 'string', 'group' => 'seo'],
            ['key' => 'meta_description',     'value' => 'A premium blog network curated by passionate authors, read by thoughtful minds.', 'type' => 'string', 'group' => 'seo'],
            ['key' => 'meta_keywords',        'value' => 'blogs, blogging, articles, writing, premium content',                              'type' => 'string', 'group' => 'seo'],
            ['key' => 'og_title',             'value' => 'Blogs Portal',                                                                  'type' => 'string', 'group' => 'seo'],
            ['key' => 'og_description',       'value' => 'Where ideas become legacy.',                                                    'type' => 'string', 'group' => 'seo'],
            ['key' => 'og_image',             'value' => '',                                                                              'type' => 'file',   'group' => 'seo'],
            ['key' => 'twitter_handle',       'value' => '',                                                                              'type' => 'string', 'group' => 'seo'],
            ['key' => 'twitter_card',         'value' => 'summary_large_image',                                                           'type' => 'string', 'group' => 'seo'],
            ['key' => 'google_analytics',     'value' => '',                                                                              'type' => 'string', 'group' => 'seo'],
            ['key' => 'google_search_console','value' => '',                                                                              'type' => 'string', 'group' => 'seo'],

            // Security
            ['key' => 'recaptcha_enabled',     'value' => '0', 'type' => 'boolean', 'group' => 'security'],
            ['key' => 'recaptcha_site_key',    'value' => '',  'type' => 'string',  'group' => 'security'],
            ['key' => 'recaptcha_secret_key',  'value' => '',  'type' => 'string',  'group' => 'security'],
            ['key' => 'recaptcha_on_login',    'value' => '1', 'type' => 'boolean', 'group' => 'security'],
            ['key' => 'recaptcha_on_register', 'value' => '1', 'type' => 'boolean', 'group' => 'security'],
            ['key' => 'recaptcha_on_contact',  'value' => '1', 'type' => 'boolean', 'group' => 'security'],
        ];

        foreach ($defaults as $row) {
            Setting::updateOrCreate(['key' => $row['key']], $row);
        }
    }
}
