<?php

namespace Database\Seeders;

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

class PrintStockSeeder extends Seeder
{
    public function run(): void
    {
        $stocks = [
            [
                'name' => 'Standard Matte',
                'description' => 'Classic matte finish wallpaper. Professional appearance with subtle texture.',
                'cost_per_meter' => 8.50,
                'cost_per_m2' => 85.00,
                'type' => 'both'
            ],
            [
                'name' => 'Premium Silk',
                'description' => 'Smooth silk finish with subtle sheen. Elegant and durable.',
                'cost_per_meter' => 12.50,
                'cost_per_m2' => 125.00,
                'type' => 'both'
            ],
            [
                'name' => 'Luxury Velvet',
                'description' => 'Rich velvet texture with premium feel. High-end luxury option.',
                'cost_per_meter' => 16.00,
                'cost_per_m2' => 160.00,
                'type' => 'both'
            ],
            [
                'name' => 'Canvas',
                'description' => 'Textured canvas finish. Great for artistic designs.',
                'cost_per_meter' => 14.00,
                'cost_per_m2' => 140.00,
                'type' => 'both'
            ],
            [
                'name' => 'Glossy',
                'description' => 'Shiny glossy finish. Vibrant colors and easy to clean.',
                'cost_per_meter' => 10.00,
                'cost_per_m2' => 100.00,
                'type' => 'both'
            ]
        ];

        foreach ($stocks as $stock) {
            PrintStock::create($stock);
        }

        // Attach all stocks to all products
        $products = Product::all();
        $stockIds = PrintStock::pluck('id')->toArray();
        
        foreach ($products as $product) {
            $product->printStocks()->sync($stockIds);
        }
    }
}
