<?php

namespace Database\Seeders\Tenant;

use App\Facades\Settings;
use Illuminate\Database\Seeder;
use Mtc\MercuryDataModels\Setting;

class SeoSitemapAdditionalSettingSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        collect($this->settings())
            ->each(fn ($setting) => Settings::make($setting));

        Setting::query()
            ->where('config_key', 'seo-sitemap-fixed-urls')
            ->update([
                'description' => 'Additional fixed URLs to include in the sitemap (one per line). '
                    . 'Use paths (e.g. about-us) or full URLs (e.g. https://careers.example.co.uk/page).',
            ]);
    }

    /**
     * ensure that settings from SEOSitemapSettingSeeder are seeded for all tenants, not just new tenants.
     * @return array[]
     */
    private function settings(): array
    {
        return [
            [
                'tab' => 'Site',
                'section' => 'SEO',
                'group' => 'Sitemap',
                'name' => 'WWW prefix',
                'config_key' => 'seo-sitemap-www-prefix',
                'type' => 'string',
                'value' => 'as-is',
                'choices' => [
                    ['value' => 'as-is', 'name' => 'As-is (use domain as configured)'],
                    ['value' => 'force-www', 'name' => 'Force www'],
                    ['value' => 'force-non-www', 'name' => 'Force non-www'],
                ],
                'description' => 'Control whether sitemap URLs include the www. prefix',
                'order' => 9,
            ],
            [
                'tab' => 'Site',
                'section' => 'SEO',
                'group' => 'Sitemap',
                'name' => 'Exclude URLs',
                'config_key' => 'seo-sitemap-exclude-urls',
                'type' => 'text',
                'value' => '',
                'description' => 'URL paths to exclude from the sitemap (one per line). '
                    . 'Use exact paths (e.g. used-cars/ford) or wildcards (e.g. used-cars/*).',
                'order' => 10,
            ],
        ];
    }
}
