78 lines
2 KiB
PHP
78 lines
2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\VineyardRow;
|
|
use App\Models\VarietyVariation;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\VineyardRow>
|
|
*/
|
|
class VineyardRowFactory extends Factory
|
|
{
|
|
protected $model = VineyardRow::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$locations = [
|
|
'North slope',
|
|
'South slope',
|
|
'East slope',
|
|
'West slope',
|
|
'Northeast slope',
|
|
'Southeast slope',
|
|
'Southwest slope',
|
|
'Northwest slope',
|
|
'Valley floor',
|
|
'Hilltop'
|
|
];
|
|
|
|
$statuses = ['active', 'inactive', 'replanting'];
|
|
|
|
return [
|
|
'variety_variation_id' => VarietyVariation::factory(),
|
|
'vine_count' => fake()->numberBetween(50, 200),
|
|
'planting_year' => fake()->numberBetween(2000, 2023),
|
|
'area' => fake()->randomFloat(2, 100.0, 800.0),
|
|
'location' => fake()->randomElement($locations),
|
|
'status' => fake()->randomElement($statuses),
|
|
'notes' => fake()->optional()->sentence(10),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the vineyard row is active.
|
|
*/
|
|
public function active(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'status' => 'active',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the vineyard row is being replanted.
|
|
*/
|
|
public function replanting(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'status' => 'replanting',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Assign the vineyard row to a specific variety variation.
|
|
*/
|
|
public function forVarietyVariation(VarietyVariation $variation): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'variety_variation_id' => $variation->getKey(),
|
|
]);
|
|
}
|
|
}
|