<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Category;

class CategorySeeder extends Seeder
{
    public function run(): void
    {
        $categories = [
            'Electronics' => ['Mobile Phones', 'Laptops & Computers', 'Audio & Headphones', 'Smart Watches'],
            'Apparel & Fashion' => ['Men\'s Clothing', 'Women\'s Clothing', 'Shoes', 'Accessories'],
            'Home & Garden' => ['Furniture', 'Kitchenware', 'Home Decor', 'Gardening Tools'],
            'Sports & Outdoors' => ['Fitness Equipment', 'Outdoor Recreation', 'Sportswear'],
            'Automotive' => ['Car Electronics', 'Interior Accessories', 'Tools & Equipment'],
        ];

        foreach ($categories as $parentName => $subcategories) {
            // Create Parent Category
            $parent = Category::create(['name' => $parentName]);

            // Create Subcategories
            foreach ($subcategories as $subName) {
                Category::create([
                    'parent_id' => $parent->id,
                    'name' => $subName,
                ]);
            }
        }
    }
}