first()], [$users->last()], [$users->first(), $users->last()], ]); $planner = Planner::all()->first() ?? Planner::factory()->create(); collect([ 'lasagne', 'pizza', 'burger', 'fries', 'salad', 'sushi', 'pancakes', 'ice cream', 'spaghetti', 'mac and cheese', 'steak', 'chicken', 'beef', 'pork', 'fish', 'chips', 'cake', ])->map(fn (string $name) => Dish::factory() ->create([ 'planner_id' => $planner->id, 'name' => $name, ]) )->each(fn (Dish $dish) => $dish->users()->attach($userOptions->random())); } }