50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
use App\Enums\StaticPageType;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\News;
|
|
use App\Models\Range;
|
|
use App\Models\StaticPage;
|
|
|
|
class NewsController extends Controller
|
|
{
|
|
/**
|
|
* Display the homepage.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index(): \Illuminate\Contracts\View\View
|
|
{
|
|
/** @var \App\Models\StaticPage $staticPageModel */
|
|
$staticPageModel = StaticPage::query()
|
|
->where('type', StaticPageType::news)
|
|
->firstOrFail();
|
|
|
|
/** @var \App\Models\Range $rangeModelList */
|
|
$rangeModelList = Range::query()->limit(3)->inRandomOrder()->get();
|
|
|
|
/** @var \App\Models\News $newsModelList */
|
|
$newsModelList = News::query()->where('published', true)->orderby('publish_at', 'ASC')->get();
|
|
|
|
return view('fo.pages.news.index', compact(
|
|
'staticPageModel',
|
|
'newsModelList',
|
|
'rangeModelList'
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Show a specific resource.
|
|
*
|
|
* @param \App\Models\News $publishedNews
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function show(News $publishedNews): \Illuminate\Contracts\View\View
|
|
{
|
|
return view('fo.pages.news.show', [
|
|
'newsModel' => $publishedNews
|
|
]);
|
|
}
|
|
}
|