*/ final 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(): array { $name = fake()->unique()->word; $ingredients = ['en' => []]; for ($jj = 1; $jj <= 9; $jj++) { array_push($ingredients['en'], [ "value" => fake()->unique()->words(\rand(2, 8), true) ]); } return [ 'seo_title' => fake()->word, 'seo_description' => fake()->text, 'name' => $name, 'slug' => Str::slug($name), 'picture_alt' => fake()->word, 'picture_title' => fake()->word, 'picture_thumbnail_alt' => fake()->word, 'picture_thumbnail_title' => fake()->word, 'ingredients' => $ingredients, 'teaser' => fake()->text, 'steps' => fake()->text, 'difficulty' => \collect(DifficultyEnum::cases())->random(), 'preparation' => fake()->numberBetween(0, 60), 'duration' => fake()->numberBetween(0, 60), 'tips' => fake()->text, 'cooking' => \collect(CookingEnum::cases())->random(), 'range_id' => fake()->randomElement(Range::pluck('id')), 'status' => fake()->boolean(75), ]; } }