<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class PageSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $pages = [
            [
                'title' => __('Home'),
                'slug' => '/',
                'is_default' => false,
            ],
            [
                'title' => __('Quiz'),
                'slug' => 'quizzes',
                'is_default' => true,
            ],
            [
                'title' => __('Contest'),
                'slug' => 'contests',
                'is_default' => true,
            ],
            [
                'title' => __('Dashboard'),
                'slug' => 'dashboard',
                'is_default' => true,
            ],
            [
                'title' => __('About Us'),
                'slug' => 'about-us',
            ],
            [
                'title' => __('Contact'),
                'slug' => 'contact-us',
            ],
            [
                'title' => __('Top Players'),
                'slug' => 'top-players',
                'is_default' => true,
            ],
            [
                'title' => __('Login'),
                'slug' => 'sign-in',
                'is_default' => true,
            ],
            [
                'title' => __('Register'),
                'slug' => 'sign-up',
                'is_default' => true,
            ],
            [
                'title' => __('Privacy Policy'),
                'slug' => 'privacy-policy',
            ],
            [
                'title' => __('Terms & Conditions'),
                'slug' => 'terms-conditions',
            ],
            [
                'title' => __('Confidentiality & Privacy'),
                'slug' => 'confidentiality-and-privacy',
            ],
            [
                'title' => __('Legal Information'),
                'slug' => 'legal-information',
            ],

        ];
        $pageSections = [
            '/' => [
                'home-hero',
                'how-it-works',
                'three-quizzes',
                'unique-quiz-features',
                'upcoming-contests',
                'the-journey',
                'testimonials',
                'counter-section',
                'subscribe-section',
                'footer',
            ],
            'quizzes' => [
                'footer',
            ],
            'contests' => [
                'footer',
            ],
            'dashboard' => [
                'footer',
            ],
            'top-players' => [
                'footer',
            ],
            'about-us' => [
                'the-journey',
                'faq-section',
                'testimonials',
                'top-players',
                'footer',
            ],
            'contact-us' => [
                'contact-us',
                'contact-form',
                'footer',
            ],
            'privacy-policy' => [
                'privacy-policy',
                'footer',
            ],
            'terms-conditions' => [
                'terms-and-conditions',
                'footer',
            ],
            'confidentiality-and-privacy' => [
                'confidentiality-and-privacy',
                'footer',
            ],
            'legal-information' => [
                'legal-information',
                'footer',
            ],
        ];
        foreach ($pages as $page) {
            $pageObject = \App\Models\Page::create($page);
            if (isset($pageSections[$page['slug']])) {
                foreach ($pageSections[$page['slug']] as $order => $section) {
                    \App\Models\PageSection::create([
                        'page_id' => $pageObject->id,
                        'section_id' => \App\Models\FrontendSection::where('slug', $section)->first()?->id,
                        'order' => $order,
                    ]);
                }
            }

        }
    }
}
