41 lines
1,019 B
PHP
41 lines
1,019 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Recipe;
|
|
|
|
class RecipesController extends Controller
|
|
{
|
|
/**
|
|
* Return a list of filtered recipes.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
$publishedRecipes = Recipe::where('status', true)
|
|
->orderBy('slug', 'ASC')->paginate(9);
|
|
|
|
return view('fo.pages.recipes.index', compact('publishedRecipes'));
|
|
}
|
|
|
|
/**
|
|
* Return a view with a specific model.
|
|
*
|
|
* @param \App\Models\Recipe $publishedRecipe
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function show(Recipe $publishedRecipe)
|
|
{
|
|
// 3 Recettes.
|
|
$publishedRecipes = Recipe::where('status', true)
|
|
->where('id', '!=', $publishedRecipe->id)
|
|
->take(3)
|
|
->get();
|
|
|
|
$recipe = $publishedRecipe;
|
|
|
|
return view('fo.pages.recipes.recipe', compact('recipe', 'publishedRecipes'));
|
|
}
|
|
}
|