2023-02-24 15:20:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
|
|
use App\Enums\CookingModeEnum;
|
|
|
|
|
use App\Enums\DifficultyEnum;
|
|
|
|
|
use App\Models\Recipe;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
|
|
class RecipeFactory extends Factory
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $model = Recipe::class;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define the model's default state.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function definition()
|
|
|
|
|
{
|
|
|
|
|
$name = $this->faker->unique()->words((int)$this->faker->randomFloat(0, 5, 6), true);
|
|
|
|
|
$video_id = '7rpgfetac0U';
|
|
|
|
|
$ingredients = [];
|
|
|
|
|
for ($jj = 1; $jj <= 15; $jj++) {
|
|
|
|
|
array_push($ingredients, [
|
|
|
|
|
'label' => $this->faker->words(rand(1, 3), true),
|
|
|
|
|
'value' => $this->faker->numberBetween(1, 20) . ' ' . substr($this->faker->words(1, true), 0, 7),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'name' => $name,
|
|
|
|
|
'slug' => Str::slug($name),
|
|
|
|
|
'seo_title' => $this->faker->words(8, true),
|
|
|
|
|
'seo_description' => $this->faker->words(15, true),
|
|
|
|
|
|
|
|
|
|
'picture' => new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/recipes/lionor-recipe-sample.jpg'
|
|
|
|
|
)),
|
|
|
|
|
'picture_alt' => $this->faker->unique()->words((int)$this->faker->randomFloat(0, 5, 6), true),
|
|
|
|
|
'picture_title' => $this->faker->unique()->words((int)$this->faker->randomFloat(0, 2, 4), true),
|
|
|
|
|
|
|
|
|
|
'sticker' => new \SplFileInfo(\resource_path(
|
|
|
|
|
'../database/factories/assets/recipes/lionor-recipe-sticker-sample.jpg'
|
|
|
|
|
)),
|
|
|
|
|
'sticker_alt' => $this->faker->unique()->words((int)$this->faker->randomFloat(0, 5, 6), true),
|
|
|
|
|
'sticker_title' => $this->faker->unique()->words((int)$this->faker->randomFloat(0, 2, 4), true),
|
|
|
|
|
|
|
|
|
|
'youtube_video_id' => $this->faker->boolean(75) ? $video_id : null,
|
|
|
|
|
|
|
|
|
|
'description' => $this->faker->words(15, true),
|
|
|
|
|
'preparation' => $this->faker->words(15, true),
|
|
|
|
|
|
|
|
|
|
'ingredients' => $ingredients,
|
|
|
|
|
'portions' => '1 à ' . (int)$this->faker->randomFloat(0, 2, 10),
|
2023-08-28 08:46:47 +00:00
|
|
|
'difficulty' => collect(DifficultyEnum::toArray())->random()->value,
|
|
|
|
|
'cooking_mode' => collect(CookingModeEnum::toArray())->random()->value,
|
2023-02-24 15:20:58 +00:00
|
|
|
'cooking_time' => $this->faker->numberBetween(0, 120),
|
|
|
|
|
'preparation_time' => $this->faker->numberBetween(0, 140),
|
|
|
|
|
'status' => $this->faker->boolean(75),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|