*/ 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, '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), ]; } public function configure(): static { return $this->afterCreating(function (Recipe $recipe) { $moments = ConsumptionMoment::all(); if ($moments->isNotEmpty()) { $recipe->consumptionMoments()->attach( $moments->random(min(random_int(1, 2), $moments->count()))->modelKeys() ); } }); } }