<?php

namespace Database\Seeders;

use App\Models\Cutting;
use App\Models\CuttingMaterial;
use App\Models\RawMaterialPrice;
use Illuminate\Database\Seeder;

class CuttingMaterialSeeder extends Seeder
{
    public function run(): void
    {
        $cutting = Cutting::query()->first();
        $rawMaterialPrice = RawMaterialPrice::query()->first();

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

            return;
        }

        CuttingMaterial::factory()
            ->count(2)
            ->create([
                'cutting_id' => $cutting->id,
                'raw_material_price_id' => $rawMaterialPrice->id,
            ]);
    }
}
