ldc-nature-and-respect/app/Http/Controllers/Fo/RecipeController.php

43 lines
1.3 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Controllers\Fo;
use App\Enums\StaticPageType;
2023-04-05 09:46:24 +00:00
use App\Http\Controllers\Controller;
use App\Models\Recipe;
use App\Models\StaticPage;
2023-05-04 19:08:24 +02:00
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)
2023-05-04 19:08:24 +02:00
->whereHas('range', fn (Builder $q) => $q->where('status', true))
2023-05-05 07:52:58 +02:00
->orderBy('order')
2023-05-04 19:08:24 +02:00
->get();
return view('fo.pages.recipes.index', compact('staticPageModel', 'recipeModels'));
}
/**
* Recipe show
*
2023-05-04 16:00:15 +02:00
* @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,
]);
}
}