-
app/Http/Controllers/Ingredients/IngredientController.php
Open in GitHubuse Illuminate\Http\Request; use App\Models\Recipes\Recipe; class IngredientController extends Controller { public function index(Request $request, Recipe $recipe) { $this->authorize([Ingredient::class, $recipe]); $ingredients = $recipe ->ingredients() ->orderBy('ingredient_group_id') ->orderBy('position') ->originalOnly() ->get(); if ($request->grouped) { return $ingredients->groupBy('ingredient_group_id'); } return $ingredients; } // }