<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\ServiceItem;
use App\Models\ServiceCategory;
use Illuminate\Support\Str;

class ServiceItemSeeder extends Seeder
{
    public function run(): void
    {
        $printingCategory = ServiceCategory::where('slug', 'printing')->first();
        $brandingCategory = ServiceCategory::where('slug', 'item-branding')->first();

        $items = [
            // Item Branding Items
            [
                'service_category_id' => $brandingCategory->id,
                'name' => 'Pen',
                'slug' => 'pen',
                'description' => 'Custom branded pens for promotional purposes',
                'base_price' => 2.50,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 1,
            ],
            [
                'service_category_id' => $brandingCategory->id,
                'name' => 'Towel',
                'slug' => 'towel',
                'description' => 'Personalized towels with custom branding',
                'base_price' => 8.00,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 2,
            ],
            [
                'service_category_id' => $brandingCategory->id,
                'name' => 'Mug',
                'slug' => 'mug',
                'description' => 'Custom printed mugs for corporate gifts',
                'base_price' => 5.50,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 3,
            ],
            [
                'service_category_id' => $brandingCategory->id,
                'name' => 'T-Shirt',
                'slug' => 't-shirt',
                'description' => 'Custom branded t-shirts for events and promotions',
                'base_price' => 12.00,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 4,
            ],
            [
                'service_category_id' => $brandingCategory->id,
                'name' => 'Tray and Other plastic Items',
                'slug' => 'tray-plastic-items',
                'description' => 'Branded plastic trays and various plastic items',
                'base_price' => 3.75,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 5,
            ],
            [
                'service_category_id' => $brandingCategory->id,
                'name' => 'Bottles',
                'slug' => 'bottles',
                'description' => 'Custom branded water bottles and drink containers',
                'base_price' => 6.25,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 6,
            ],
            [
                'service_category_id' => $brandingCategory->id,
                'name' => 'Nylon',
                'slug' => 'nylon',
                'description' => 'Custom printed nylon bags and materials',
                'base_price' => 1.50,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 7,
            ],
            [
                'service_category_id' => $brandingCategory->id,
                'name' => 'Cap',
                'slug' => 'cap',
                'description' => 'Custom embroidered or printed caps',
                'base_price' => 7.50,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 8,
            ],
            // Printing Items
            [
                'service_category_id' => $printingCategory->id,
                'name' => 'Business Card',
                'slug' => 'business-card',
                'description' => 'Professional business cards with custom finishes',
                'base_price' => 0.25,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 1,
            ],
            [
                'service_category_id' => $printingCategory->id,
                'name' => 'Paper Bag',
                'slug' => 'paper-bag',
                'description' => 'Custom printed paper bags for retail',
                'base_price' => 0.75,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 2,
            ],
            [
                'service_category_id' => $printingCategory->id,
                'name' => 'Jotter (Hard Cover)',
                'slug' => 'jotter-hard-cover',
                'description' => 'Custom branded hard cover notebooks',
                'base_price' => 4.50,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 3,
            ],
            [
                'service_category_id' => $printingCategory->id,
                'name' => 'Invite',
                'slug' => 'invite',
                'description' => 'Custom printed invitations for events',
                'base_price' => 1.25,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 4,
            ],
            [
                'service_category_id' => $printingCategory->id,
                'name' => 'Access Card',
                'slug' => 'access-card',
                'description' => 'Custom printed access cards and ID cards',
                'base_price' => 2.00,
                'unit' => 'piece',
                'is_active' => true,
                'sort_order' => 5,
            ],
        ];

        foreach ($items as $item) {
            ServiceItem::updateOrCreate(
                ['slug' => $item['slug']],
                $item
            );
        }
    }
}
