<?php

namespace Database\Seeders;

use App\Models\Cutting;
use App\Models\CuttingResult;
use App\Models\ProductVariant;
use Illuminate\Database\Seeder;

class CuttingResultSeeder extends Seeder
{
    public function run(): void
    {
        $cutting = Cutting::query()->first();
        $variant = ProductVariant::query()->first();

        if ($cutting === null || $variant === null) {
            CuttingResult::factory()->count(3)->create();

            return;
        }

        CuttingResult::factory()
            ->count(2)
            ->create([
                'cutting_id' => $cutting->id,
                'product_variant_id' => $variant->id,
            ]);
    }
}
