<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class ExtendCategoriesSeeder extends Seeder
{
    /**
     * Run to extend the SiteContents categories without refreshing the database.
     * Step 1: php artisan db:seed --class=ExtendCategoriesSeeder
     * Step 2: php artisan db:seed --class=ExtendCategoryTranslationsSeeder
     *
     */
    public function run(): void
    {
        $categories = [
            ['type' => 'SiteContents\\Static\\WhyJoin'],
            ['type' => 'SiteContents\\Search\\Info'],
            ['type' => 'SiteContents\\Contacts'],
            ['type' => 'SiteContents\\Manage\\Posts'],
            ['type' => 'SiteContents\\Manage\\Calls'],
            ['type' => 'SiteContents\\Manage\\CallsAdmin'],
            ['type' => 'SiteContents\\Manage\\Categories'],
            ['type' => 'SiteContents\\Manage\\Tags'],
            ['type' => 'SiteContents\\Manage\\Profiles'],
            ['type' => 'SiteContents\\Manage\\Permissions'],
            ['type' => 'SiteContents\\Manage\\Roles'],
            ['type' => 'SiteContents\\Messenger\\Announcement'],
            ['type' => 'SiteContents\\Terms'],
            ['type' => 'SiteContents\\PrivacyPolicy'],
            ['type' => 'SiteContents\\AccountUsage\\Info'],
            ['type' => 'SiteContents\\Search\\Hints'],
            ['type' => 'SiteContents\\Search\\NoResults'],
            ['type' => 'SiteContents\\Errors\\503'],
            ['type' => 'SiteContents\\Errors\\500'],
            ['type' => 'SiteContents\\Errors\\429'],
            ['type' => 'SiteContents\\Errors\\419'],
            ['type' => 'SiteContents\\Errors\\404'],
            ['type' => 'SiteContents\\Errors\\403'],
            ['type' => 'SiteContents\\Errors\\402'],
            ['type' => 'SiteContents\\Errors\\401'],
            ['type' => 'SiteContents\\Report\\Error'],
            ['type' => 'SiteContents\\Report\\Issue'],
            ['type' => 'SiteContents\\MaintenanceAnnouncement'],
            ['type' => 'SiteContents\\ProfileIncomplete'],
            ['type' => 'App\\Models\\ImagePost'],
            ['type' => 'App\\Models\\ImagePost\\en'],
            ['type' => 'App\\Models\\ImagePost\\fr'],
            ['type' => 'App\\Models\\ImagePost\\nl'],
            ['type' => 'App\\Models\\ImagePost\\es'],
            ['type' => 'App\\Models\\ImagePost\\de'],
            ['type' => 'SiteContents\\Call\\NotAllowed'],
            ['type' => 'SiteContents\\Static\\OpenSource'],

        ];

        foreach ($categories as $category) {
            $exists = DB::table('categories')->where('type', $category['type'])->exists();

            if (!$exists) {
                DB::table('categories')->insert($category);
            }
        }
    }
}
