<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class DelayedGoodSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $customers = \App\Models\Customer::all();
        $units = \App\Models\Unit::all();

        if ($customers->isEmpty()) {
            $customers = \App\Models\Customer::factory()->count(10)->create();
        }

        if ($units->isEmpty()) {
            $units = \App\Models\Unit::factory()->count(5)->create();
        }

        \App\Models\DelayedGood::factory()
            ->count(50)
            ->recycle($customers)
            ->recycle($units)
            ->create();
    }
}
