isEmpty()) { $this->command->warn('Aucun produit trouvé. Exécutez le ProductSeeder en premier.'); return; } Recipe::factory() ->count(30) ->create() ->each(function (Recipe $recipe) use ($products) { $recipe->products()->attach( $products->random(random_int(1, 4))->pluck('id')->toArray() ); }); } }