Projects/3BIT/winter-semester/IIS/xnecasr00/database/factories/TreatmentFactory.php
2026-04-14 19:28:46 +02:00

38 lines
863 B
PHP

<?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(),
]);
}
}