2023-02-24 15:20:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
|
|
2026-06-11 17:04:36 +02:00
|
|
|
use App\Enums\StaticPageType;
|
2023-02-24 15:20:58 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
2023-03-09 10:27:19 +00:00
|
|
|
use App\Models\Range;
|
|
|
|
|
use App\Models\Recipe;
|
2026-06-11 17:04:36 +02:00
|
|
|
use App\Models\StaticPage;
|
2023-02-24 15:20:58 +00:00
|
|
|
|
|
|
|
|
class HomeController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Display a listing of the resource.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
2026-06-11 17:04:36 +02:00
|
|
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::homepage)->first();
|
|
|
|
|
|
2023-03-09 10:27:19 +00:00
|
|
|
// Gammes.
|
2024-09-06 08:30:55 +00:00
|
|
|
$ranges = Range::query()->where('status', true)
|
2023-03-09 10:27:19 +00:00
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
// 3 Recettes.
|
2024-09-06 08:30:55 +00:00
|
|
|
$publishedRecipes = Recipe::query()
|
|
|
|
|
->where('status', true)
|
2023-06-07 12:48:59 +00:00
|
|
|
->inRandomOrder()
|
2023-03-09 10:27:19 +00:00
|
|
|
->take(3)
|
|
|
|
|
->get();
|
|
|
|
|
|
2026-06-11 17:04:36 +02:00
|
|
|
return view('fo.pages.home', compact('staticPageModel', 'ranges', 'publishedRecipes'));
|
2023-02-24 15:20:58 +00:00
|
|
|
}
|
|
|
|
|
}
|