<?php

namespace Database\Seeders;

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

class ProductVariantSeeder extends Seeder
{
    public function run(): void
    {
        Product::query()
            ->whereDoesntHave('variants')
            ->each(function (Product $product): void {
                foreach (['S', 'M', 'L'] as $size) {
                    ProductVariant::factory()->create([
                        'product_id' => $product->id,
                        'name' => $size,
                    ]);
                }
            });
    }
}
