<?php

namespace Database\Seeders;

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

class ProductSeeder extends Seeder
{
    public function run(): void
    {
        $categories = Category::all();

        $products = [
            ['name' => 'Wireless Mouse', 'sku' => 'ELEC-001', 'barcode' => '123456789001', 'category_id' => 1, 'cost_price' => 15.00, 'selling_price' => 25.00, 'stock_quantity' => 50, 'low_stock_threshold' => 10],
            ['name' => 'USB Keyboard', 'sku' => 'ELEC-002', 'barcode' => '123456789002', 'category_id' => 1, 'cost_price' => 20.00, 'selling_price' => 35.00, 'stock_quantity' => 30, 'low_stock_threshold' => 10],
            ['name' => 'HDMI Cable', 'sku' => 'ELEC-003', 'barcode' => '123456789003', 'category_id' => 1, 'cost_price' => 5.00, 'selling_price' => 12.00, 'stock_quantity' => 100, 'low_stock_threshold' => 20],
            ['name' => 'Cotton T-Shirt', 'sku' => 'CLTH-001', 'barcode' => '223456789001', 'category_id' => 2, 'cost_price' => 8.00, 'selling_price' => 15.00, 'stock_quantity' => 200, 'low_stock_threshold' => 30],
            ['name' => 'Denim Jeans', 'sku' => 'CLTH-002', 'barcode' => '223456789002', 'category_id' => 2, 'cost_price' => 25.00, 'selling_price' => 45.00, 'stock_quantity' => 75, 'low_stock_threshold' => 15],
            ['name' => 'Baseball Cap', 'sku' => 'CLTH-003', 'barcode' => '223456789003', 'category_id' => 2, 'cost_price' => 5.00, 'selling_price' => 12.00, 'stock_quantity' => 150, 'low_stock_threshold' => 25],
            ['name' => 'Bottled Water', 'sku' => 'FOOD-001', 'barcode' => '323456789001', 'category_id' => 3, 'cost_price' => 0.50, 'selling_price' => 1.50, 'stock_quantity' => 500, 'low_stock_threshold' => 100],
            ['name' => 'Energy Bar', 'sku' => 'FOOD-002', 'barcode' => '323456789002', 'category_id' => 3, 'cost_price' => 1.00, 'selling_price' => 2.50, 'stock_quantity' => 300, 'low_stock_threshold' => 50],
            ['name' => 'Coffee Cup', 'sku' => 'FOOD-003', 'barcode' => '323456789003', 'category_id' => 3, 'cost_price' => 2.00, 'selling_price' => 5.00, 'stock_quantity' => 200, 'low_stock_threshold' => 30],
            ['name' => 'Garden Hose', 'sku' => 'HOME-001', 'barcode' => '423456789001', 'category_id' => 4, 'cost_price' => 15.00, 'selling_price' => 25.00, 'stock_quantity' => 40, 'low_stock_threshold' => 10],
            ['name' => 'Plant Pot', 'sku' => 'HOME-002', 'barcode' => '423456789002', 'category_id' => 4, 'cost_price' => 3.00, 'selling_price' => 7.00, 'stock_quantity' => 100, 'low_stock_threshold' => 20],
            ['name' => 'LED Bulb', 'sku' => 'HOME-003', 'barcode' => '423456789003', 'category_id' => 4, 'cost_price' => 4.00, 'selling_price' => 10.00, 'stock_quantity' => 80, 'low_stock_threshold' => 15],
            ['name' => 'Basketball', 'sku' => 'SPRT-001', 'barcode' => '523456789001', 'category_id' => 5, 'cost_price' => 15.00, 'selling_price' => 25.00, 'stock_quantity' => 50, 'low_stock_threshold' => 10],
            ['name' => 'Tennis Racket', 'sku' => 'SPRT-002', 'barcode' => '523456789002', 'category_id' => 5, 'cost_price' => 30.00, 'selling_price' => 50.00, 'stock_quantity' => 20, 'low_stock_threshold' => 5],
            ['name' => 'Yoga Mat', 'sku' => 'SPRT-003', 'barcode' => '523456789003', 'category_id' => 5, 'cost_price' => 10.00, 'selling_price' => 20.00, 'stock_quantity' => 60, 'low_stock_threshold' => 15],
            ['name' => 'Vitamin C', 'sku' => 'HLTH-001', 'barcode' => '623456789001', 'category_id' => 6, 'cost_price' => 5.00, 'selling_price' => 12.00, 'stock_quantity' => 100, 'low_stock_threshold' => 20],
            ['name' => 'Shampoo', 'sku' => 'HLTH-002', 'barcode' => '623456789002', 'category_id' => 6, 'cost_price' => 4.00, 'selling_price' => 8.00, 'stock_quantity' => 150, 'low_stock_threshold' => 25],
            ['name' => 'Hand Cream', 'sku' => 'HLTH-003', 'barcode' => '623456789003', 'category_id' => 6, 'cost_price' => 3.00, 'selling_price' => 6.00, 'stock_quantity' => 80, 'low_stock_threshold' => 15],
            ['name' => 'Puzzle Game', 'sku' => 'TOYS-001', 'barcode' => '723456789001', 'category_id' => 7, 'cost_price' => 8.00, 'selling_price' => 15.00, 'stock_quantity' => 60, 'low_stock_threshold' => 10],
            ['name' => 'Action Figure', 'sku' => 'TOYS-002', 'barcode' => '723456789002', 'category_id' => 7, 'cost_price' => 10.00, 'selling_price' => 20.00, 'stock_quantity' => 40, 'low_stock_threshold' => 10],
            ['name' => 'Notebook', 'sku' => 'OFFC-001', 'barcode' => '823456789001', 'category_id' => 8, 'cost_price' => 1.00, 'selling_price' => 3.00, 'stock_quantity' => 500, 'low_stock_threshold' => 100],
            ['name' => 'Ballpoint Pen', 'sku' => 'OFFC-002', 'barcode' => '823456789002', 'category_id' => 8, 'cost_price' => 0.25, 'selling_price' => 1.00, 'stock_quantity' => 1000, 'low_stock_threshold' => 200],
            ['name' => 'Stapler', 'sku' => 'OFFC-003', 'barcode' => '823456789003', 'category_id' => 8, 'cost_price' => 3.00, 'selling_price' => 7.00, 'stock_quantity' => 50, 'low_stock_threshold' => 10],
        ];

        foreach ($products as $product) {
            Product::create([
                'name' => $product['name'],
                'sku' => $product['sku'],
                'barcode' => $product['barcode'],
                'category_id' => $product['category_id'],
                'cost_price' => $product['cost_price'],
                'selling_price' => $product['selling_price'],
                'stock_quantity' => $product['stock_quantity'],
                'low_stock_threshold' => $product['low_stock_threshold'],
                'is_active' => true,
                'description' => $product['name'].' - High quality product',
            ]);
        }
    }
}
