ldc-nature-and-respect/app/Http/Controllers/Fo/RecipeController.php
2023-04-05 09:46:24 +00:00

43 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers\Fo;
use App\Http\Controllers\Controller;
use App\Models\Recipe;
class RecipeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\View\View
*/
public function index()
{
// Get recipies.
$recipes = Recipe::where('status', '1')->get();
// Filter poultry.
$poultries = $recipes->unique('range_id')->pluck('range_id');
// Filter difficulty.
$difficulties = $recipes->unique('difficulty')->pluck('difficulty');
return view('fo.pages.recipes.index', compact(['recipes', 'poultries', 'difficulties']));
}
/**
* Recipe show
*
* @param mixed $id
* @return \Illuminate\Contracts\View\View
*/
public function show(mixed $id)
{
$recipe = Recipe::where('id', $id)->first();
if ($recipe == null) {
$recipe = Recipe::where('slug', $id)->first();
if ($recipe == null) {
abort(404);
}
}
return view('fo.pages.recipes.show', compact(['recipe']));
}
}