<?php

namespace Database\Factories;

use App\Models\GrapeVariety;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\GrapeVariety>
 */
class GrapeVarietyFactory extends Factory
{
    protected $model = GrapeVariety::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $varieties = [
            'Chardonnay', 'Sauvignon Blanc', 'Riesling', 'Pinot Grigio', 'Gewürztraminer',
            'Cabernet Sauvignon', 'Merlot', 'Pinot Noir', 'Syrah', 'Malbec',
            'Grüner Veltliner', 'Blaufränkisch', 'St. Laurent', 'Müller Thurgau'
        ];

        $wineTypes = ['white', 'red', 'rose'];
        $selectedType = fake()->randomElement($wineTypes);

        return [
            'variety_name' => fake()->randomElement($varieties) . ' ' . fake()->unique()->word(),
            'description' => fake()->paragraph(3),
            'origin' => fake()->country(),
            'wine_type' => $selectedType,
            'characteristics' => fake()->sentence(6),
            'image_url' => fake()->optional()->imageUrl(640, 480, 'wine', true),
        ];
    }

    /**
     * Indicate that the variety is for white wine.
     */
    public function white(): static
    {
        return $this->state(fn (array $attributes) => [
            'wine_type' => 'white',
        ]);
    }

    /**
     * Indicate that the variety is for red wine.
     */
    public function red(): static
    {
        return $this->state(fn (array $attributes) => [
            'wine_type' => 'red',
        ]);
    }

    /**
     * Indicate that the variety is for rosé wine.
     */
    public function rose(): static
    {
        return $this->state(fn (array $attributes) => [
            'wine_type' => 'rose',
        ]);
    }
}
