54 lines
2.2 KiB
PHP
54 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Recipes\DifficultyEnum;
|
|
use App\Models\ConsumptionMoment;
|
|
use App\Models\Video;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
class RecipeFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$title = fake()->words(3, true);
|
|
$ingredientsList = [];
|
|
$ingredientsListAmount = fake()->numberBetween(1, 5);
|
|
for ($jj = 1; $jj <= $ingredientsListAmount; $jj++) {
|
|
array_push($ingredientsList, [
|
|
'value' => fake()->numberBetween(10, 50),
|
|
'label_unit' => fake()->words(5, true),
|
|
'label_value' => fake()->words(5, true),
|
|
'is_proportionnal' => fake()->boolean(50),
|
|
]);
|
|
}
|
|
|
|
return [
|
|
'seo_title' => fake()->sentence(),
|
|
'seo_description' => fake()->sentence(),
|
|
'slug' => Str::slug($title),
|
|
'title' => $title,
|
|
'tips' => fake()->sentence(),
|
|
'picture' => '',
|
|
'picture_alt' => fake()->words(8, true),
|
|
'picture_title' => fake()->words(5, true),
|
|
'ingredients_list' => $ingredientsList,
|
|
'preparation' => fake()->sentence(),
|
|
'advice' => fake()->sentence(),
|
|
'video_id' => fake()->boolean(50) ? \collect(Video::all())->random() : null,
|
|
'consumption_moment_id' => \collect(ConsumptionMoment::all())->random(),
|
|
'preparation_time' => fake()->numberBetween(1, 100),
|
|
'cooking_time' => fake()->numberBetween(1, 100),
|
|
'nb_guests' => fake()->numberBetween(1, 10),
|
|
'difficulty' => \collect(DifficultyEnum::toArray())->random()->value,
|
|
'highlight' => fake()->boolean(75),
|
|
'published' => fake()->boolean(75),
|
|
];
|
|
}
|
|
}
|