<?php

namespace Database\Seeders;

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

class ProductSeeder extends Seeder
{
    public function run(): void
    {
        $kursi = Category::where('category_name', 'Kursi')->first();
        $meja = Category::where('category_name', 'Meja')->first();
        $lemari = Category::where('category_name', 'Lemari')->first();

        Product::create([
            'category_id' => $kursi->category_id,
            'product_name' => 'Kursi Kayu Minimalis',
            'description' => 'Kursi kayu dengan desain minimalis',
            'price' => 250000,
            'stock' => 10,
            'weight' => 5000,
            'image' => json_encode(['kursi1.jpg']),
        ]);

        Product::create([
            'category_id' => $meja->category_id,
            'product_name' => 'Meja Makan Jati',
            'description' => 'Meja makan berbahan kayu jati',
            'price' => 1500000,
            'stock' => 5,
            'weight' => 20000,
            'image' => json_encode(['meja1.jpg']),
        ]);

        Product::create([
            'category_id' => $lemari->category_id,
            'product_name' => 'Lemari Pakaian 2 Pintu',
            'description' => 'Lemari besar dengan 2 pintu',
            'price' => 2000000,
            'stock' => 3,
            'weight' => 30000,
            'image' => json_encode(['lemari1.jpg']),
        ]);
    }
}