2023-12-15 15:53:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
|
|
|
|
|
|
use App\Enums\StaticPageType;
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Models\KlubBloc;
|
|
|
|
|
use App\Models\News;
|
|
|
|
|
use App\Models\Range;
|
|
|
|
|
use App\Models\StaticPage;
|
|
|
|
|
|
|
|
|
|
class HomeController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Display the homepage.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
|
|
|
|
public function index(): \Illuminate\Contracts\View\View
|
|
|
|
|
{
|
2024-01-26 16:24:14 +01:00
|
|
|
/** @var \App\Models\Range $rangeModels */
|
|
|
|
|
$rangeModels = Range::query()->limit(3)->inRandomOrder()->get();
|
|
|
|
|
|
|
|
|
|
/** @var \App\Models\News $newsModels */
|
|
|
|
|
$newsModels = News::query()->where('published', true)->orderBy('created_at', 'desc')->limit(6)->get();
|
|
|
|
|
|
|
|
|
|
/** @var \App\Models\StaticPage $staticPageModel */
|
2023-12-15 17:11:06 +01:00
|
|
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->firstOrFail();
|
|
|
|
|
|
2024-01-26 16:24:14 +01:00
|
|
|
/** @var \App\Models\KlubBloc|null $klubBloc */
|
|
|
|
|
$klubBloc = KlubBloc::query()->first();
|
|
|
|
|
|
|
|
|
|
\throw_if(is_null($klubBloc), 'empty klubBloc');
|
2023-12-15 17:11:06 +01:00
|
|
|
|
2023-12-15 15:53:55 +00:00
|
|
|
return view('fo.pages.home', compact('staticPageModel', 'rangeModels', 'klubBloc', 'newsModels'));
|
|
|
|
|
}
|
|
|
|
|
}
|