image = $faker->imageUrl(640, 480, 'food'); $recipe->state = 'active'; $recipe->type = $faker->randomElement(['first_meals', 'second_meals', 'salads', 'snacks', 'drinks', 'other']); $recipe->title = $faker->sentence(5); $recipe->video_url = $faker->url; $recipe->cooking_time = $faker->randomElement([10,20,30,60,120,14400]); $recipe->description = $faker->text(200); $recipe->steps = [ ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)], ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)], ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)] ]; $recipe->ingredients = [ ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], ]; $recipe->save(); DB::table('recipe_author')->insert([ 'recipe_id' => $recipe->id, 'user_id' => User::inRandomOrder()->first()->id ]); } } }