<?php

namespace Database\Seeders\Tenant;

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

class SocialMediaSettingSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * Ensures the full set of Social Media settings exists. Earlier tenants only received the platforms
     * present in BaseSettingSeeder at the time they were seeded, and TikTok was never registered at all,
     * leaving new and existing sites with an incomplete set. Settings::make() is an updateOrCreate on
     * config_key that preserves existing values, so this safely backfills any missing platforms.
     *
     * @return void
     */
    public function run()
    {
        collect($this->data())
            ->each(fn ($setting) => Settings::make($setting));
    }

    private function data(): array
    {
        return [
            [
                'tab' => 'Site',
                'section' => 'Social Media',
                'group' => 'Social Media Icons',
                'name' => 'Facebook',
                'config_key' => 'app-socials-facebook',
                'value' => '',
                'type' => 'string',
                'description' => 'Link to the linked Facebook profile',
            ],
            [
                'tab' => 'Site',
                'section' => 'Social Media',
                'group' => 'Social Media Icons',
                'name' => 'Twitter',
                'config_key' => 'app-socials-twitter',
                'value' => '',
                'type' => 'string',
                'description' => 'Link to the linked Twitter profile',
            ],
            [
                'tab' => 'Site',
                'section' => 'Social Media',
                'group' => 'Social Media Icons',
                'name' => 'YouTube',
                'config_key' => 'app-socials-youtube',
                'value' => '',
                'type' => 'string',
                'description' => 'Link to the linked YouTube profile',
            ],
            [
                'tab' => 'Site',
                'section' => 'Social Media',
                'group' => 'Social Media Icons',
                'name' => 'Instagram',
                'config_key' => 'app-socials-instagram',
                'value' => '',
                'type' => 'string',
                'description' => 'Link to the linked Instagram profile',
            ],
            [
                'tab' => 'Site',
                'section' => 'Social Media',
                'group' => 'Social Media Icons',
                'name' => 'LinkedIn',
                'config_key' => 'app-socials-linkedin',
                'value' => '',
                'type' => 'string',
                'description' => 'Link to the linked LinkedIn profile',
            ],
            [
                'tab' => 'Site',
                'section' => 'Social Media',
                'group' => 'Social Media Icons',
                'name' => 'TikTok',
                'config_key' => 'app-socials-tiktok',
                'value' => '',
                'type' => 'string',
                'description' => 'Link to the linked TikTok profile',
            ],
        ];
    }
}
