*/ class TreatmentFactory extends Factory { protected $model = Treatment::class; /** * Define the model's default state. * * @return array */ 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(), ]); } }