<?php

namespace Database\Factories;

use App\Models\Treatment;
use App\Models\VineyardRow;
use Illuminate\Database\Eloquent\Factories\Factory;

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

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'row_id' => VineyardRow::factory(),
            'note' => fake()->optional()->sentence(8),
        ];
    }

    /**
     * Associate the treatment with a specific vineyard row.
     */
    public function forVineyardRow(VineyardRow $row): static
    {
        return $this->state(fn (array $attributes) => [
            'row_id' => $row->getKey(),
        ]);
    }
}
