67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\VarietyVariation;
|
|
use App\Models\GrapeVariety;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\VarietyVariation>
|
|
*/
|
|
class VarietyVariationFactory extends Factory
|
|
{
|
|
protected $model = VarietyVariation::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$colors = ['green', 'blue', 'yellow', 'red'];
|
|
$statuses = ['active', 'inactive'];
|
|
|
|
$ripeningPeriods = [
|
|
'Early September',
|
|
'Mid-September',
|
|
'Late September',
|
|
'Early October',
|
|
'Mid-October',
|
|
'Late October',
|
|
'September - early October',
|
|
'Late September - mid-October'
|
|
];
|
|
|
|
return [
|
|
'grape_variety_id' => GrapeVariety::factory(),
|
|
'color' => fake()->randomElement($colors),
|
|
'description' => fake()->sentence(8),
|
|
'typical_sugar_content' => fake()->randomFloat(2, 16.0, 25.0),
|
|
'typical_alcohol' => fake()->randomFloat(2, 10.0, 14.5),
|
|
'ripening_period' => fake()->randomElement($ripeningPeriods),
|
|
'status' => fake()->randomElement($statuses),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the variation is active.
|
|
*/
|
|
public function active(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'status' => 'active',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the variation is inactive.
|
|
*/
|
|
public function inactive(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'status' => 'inactive',
|
|
]);
|
|
}
|
|
}
|