<?php

namespace Database\Factories;

use App\Models\Recipe;
use App\Models\RecipeIngredient;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<RecipeIngredient>
 */
class RecipeIngredientFactory extends Factory
{
    protected $model = RecipeIngredient::class;

    public function definition(): array
    {
        return [
            'recipe_id' => Recipe::factory(),
            'ingredient_name' => fake()->randomElement([
                'شیر', 'تخم مرغ', 'سینه مرغ', 'پیاز', 'سیر',
                'گوجه فرنگی', 'برنج', 'روغن', 'نمک', 'فلفل',
            ]),
            'quantity' => (string) fake()->randomFloat(1, 0.5, 5),
            'unit' => fake()->randomElement(['g', 'kg', 'pcs', 'l', 'ml']),
            'is_optional' => false,
        ];
    }

    public function optional(): static
    {
        return $this->state(fn () => [
            'is_optional' => true,
        ]);
    }
}
