<?php

namespace Database\Seeders;

use App\Models\MasterMenu;
use App\Models\MasterStand;
use Illuminate\Database\Seeder;

class MasterMenuSeeder extends Seeder
{
    public function run(): void
    {
        $standIds = MasterStand::query()->pluck('id')->all();

        if (empty($standIds)) {
            $standIds = MasterStand::factory()->count(3)->create(['is_active' => true])->pluck('id')->all();
        }

        MasterMenu::factory()
            ->count(15)
            ->state(function () use ($standIds) {
                return [
                    'id_stand' => $standIds[array_rand($standIds)],
                    'is_active' => true,
                ];
            })
            ->create();
    }
}
