Skip to main content

ammannbe/RecipeManager

37 stars
1 code files
View ammannbe/RecipeManager on GitHub

app/Http/Controllers/Ingredients/IngredientController.php

Open in GitHub
use 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;
}
//
}