<?php

namespace Database\Seeders\Tenant;

use App\Facades\Settings;
use Illuminate\Database\Seeder;

class SiteAccessRequestSeed extends Seeder
{
    public function run(): void
    {
        collect($this->data())
            ->each(fn ($setting) => Settings::make($setting));
    }

    private function data(): array
    {
        return [
            [
                'tab' => 'Site',
                'section' => 'General',
                'group' => 'Restricted access',
                'name' => 'Access mode',
                'config_key' => 'site-access-mode',
                'type' => 'string',
                'value' => 'password',
                'description' => 'How customers are gated when restricted access is enabled.',
                'choices' => [
                    [
                        'value' => 'password',
                        'name' => 'Shared password',
                    ],
                    [
                        'value' => 'email-request',
                        'name' => 'Request access by email',
                    ],
                ],
            ],
            [
                'tab' => 'Site',
                'section' => 'General',
                'group' => 'Restricted access',
                'name' => 'Whitelisted email domains',
                'config_key' => 'site-access-whitelisted-domains',
                'type' => 'text_area',
                'value' => '',
                'description' => 'Comma-separated list of email domains permitted to request access (e.g. mtc.co.uk, partner.com).',
                'validation_rules' => [
                    'required_if:values.site-access-mode,email-request',
                ],
            ],
        ];
    }
}
