ldc-lionor/app/Http/Controllers/Fo/RecipesController.php

42 lines
1,019 B
PHP
Raw Normal View History

2023-03-09 10:27:19 +00:00
<?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()
{
2023-03-10 15:33:15 +00:00
$publishedRecipes = Recipe::where('status', true)
2023-03-09 10:27:19 +00:00
->orderBy('slug', 'ASC')->paginate(9);
2023-03-10 15:33:15 +00:00
return view('fo.pages.recipes.index', compact('publishedRecipes'));
2023-03-09 10:27:19 +00:00
}
/**
* Return a view with a specific model.
*
* @param \App\Models\Recipe $publishedRecipe
* @return \Illuminate\Contracts\View\View
*/
public function show(Recipe $publishedRecipe)
{
2023-03-10 13:02:48 +00:00
// 3 Recettes.
$publishedRecipes = Recipe::where('status', true)
2023-03-10 15:33:15 +00:00
->where('id', '!=', $publishedRecipe->id)
2023-03-10 13:02:48 +00:00
->take(3)
->get();
2023-03-10 15:33:15 +00:00
$recipe = $publishedRecipe;
2023-03-10 13:02:48 +00:00
return view('fo.pages.recipes.recipe', compact('recipe', 'publishedRecipes'));
2023-03-09 10:27:19 +00:00
}
}