ldc-wenn-dann-mit-respekt/app/Http/Controllers/Fo/RecipeController.php
2025-07-16 16:19:37 +02:00

42 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers\Fo;
use App\Enums\StaticPageType;
use App\Http\Controllers\Controller;
use App\Models\Recipe;
use App\Models\StaticPage;
use Illuminate\Contracts\Database\Eloquent\Builder;
class RecipeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\View\View
*/
public function index(): \Illuminate\Contracts\View\View
{
$staticPageModel = StaticPage::query()->where('type', StaticPageType::recipes)->firstOrFail();
$recipeModels = Recipe::query()->where('status', true)
->whereHas('range', fn (Builder $q) => $q->where('status', true))
->orderBy('order')
->get();
return view('fo.pages.recipes.index', compact('staticPageModel', 'recipeModels'));
}
/**
* Recipe show
*
* @param \App\Models\Recipe $publishedRecipe
* @return \Illuminate\Contracts\View\View
*/
public function show(Recipe $publishedRecipe): \Illuminate\Contracts\View\View
{
$staticPageModel = StaticPage::query()->where('type', StaticPageType::recipe)->firstOrFail();
return view('fo.pages.recipes.show', [
'staticPageModel' => $staticPageModel,
'recipeModel' => $publishedRecipe,
]);
}
}