42 lines
1 KiB
PHP
42 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Recipe;
|
|
|
|
class RecipeController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
// Get recipies.
|
|
$recipes = Recipe::where('live', '1')->get();
|
|
// Filter poultry.
|
|
$poultries = $recipes->unique('cat')->pluck('cat');
|
|
// Filter difficulty.
|
|
$difficulties = $recipes->unique('difficulty')->pluck('difficulty');
|
|
return view('pages.rezepte', 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('pages.rezept', compact(['recipe']));
|
|
}
|
|
}
|