<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Menu;

class MenuSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Clear existing menus
        Menu::truncate();
        
        // Create main menu items
        $menus = [
            [
                'title' => 'Dashboard',
                'icon' => 'bi bi-speedometer2',
                'route_name' => 'admin.dashboard',
                'sort_order' => 10,
                'is_active' => true,
            ],
            [
                'title' => 'Content Management',
                'icon' => 'bi bi-folder',
                'sort_order' => 20,
                'is_active' => true,
                'children' => [
                    [
                        'title' => 'Content Sections',
                        'icon' => 'bi bi-file-text',
                        'route_name' => 'admin.content-sections.index',
                        'sort_order' => 10,
                        'is_active' => true,
                    ],
                    [
                        'title' => 'Statistics',
                        'icon' => 'bi bi-bar-chart',
                        'route_name' => 'admin.statistics.index',
                        'sort_order' => 20,
                        'is_active' => true,
                    ],
                    [
                        'title' => 'Impact Numbers',
                        'icon' => 'bi bi-graph-up',
                        'route_name' => 'admin.impact-numbers.index',
                        'sort_order' => 30,
                        'is_active' => true,
                    ],
                    [
                        'title' => 'Why Select LECL',
                        'icon' => 'bi bi-star',
                        'route_name' => 'admin.why-lecl.index',
                        'sort_order' => 40,
                        'is_active' => true,
                    ],
                    [
                        'title' => 'Destinations',
                        'icon' => 'bi bi-globe',
                        'route_name' => 'admin.destinations.index',
                        'sort_order' => 50,
                        'is_active' => true,
                    ],
                ]
            ],
            [
                'title' => 'Partners & Testimonials',
                'icon' => 'bi bi-people',
                'sort_order' => 30,
                'is_active' => true,
                'children' => [
                    [
                        'title' => 'University Partners',
                        'icon' => 'bi bi-mortarboard',
                        'route_name' => 'admin.university-partners.index',
                        'sort_order' => 10,
                        'is_active' => true,
                    ],
                    [
                        'title' => 'Student Success Stories',
                        'icon' => 'bi bi-chat-quote',
                        'route_name' => 'admin.testimonials.index',
                        'sort_order' => 20,
                        'is_active' => true,
                    ],
                ]
            ],
        ];
        
        foreach ($menus as $menuData) {
            $children = $menuData['children'] ?? [];
            unset($menuData['children']);
            
            $menu = Menu::create($menuData);
            
            foreach ($children as $childData) {
                $childData['parent_id'] = $menu->id;
                Menu::create($childData);
            }
        }
        
        $this->command->info('Menu items seeded successfully!');
    }
}
