ldc-volena/app/Http/Controllers/Fo/HomeController.php

54 lines
1.8 KiB
PHP
Raw Normal View History

2023-11-13 11:56:06 +01:00
<?php
namespace App\Http\Controllers\Fo;
2024-03-13 12:28:35 +01:00
use App\Enums\Sections\PageSectionEnum;
2024-02-26 10:34:05 +01:00
use App\Enums\Slides\SliderTypeEnum;
use App\Enums\StaticPageType;
2023-11-13 11:56:06 +01:00
use App\Http\Controllers\Controller;
2024-02-26 10:34:05 +01:00
use App\Models\News;
use App\Models\Section;
use App\Models\Slide;
use App\Models\StaticPage;
use App\Models\Strip;
2023-11-13 11:56:06 +01:00
class HomeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\View\View
*/
public function index(): \Illuminate\Contracts\View\View
{
2024-02-26 10:34:05 +01:00
$staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->first();
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
$stripModels = Strip::query()->where('published', true)
->orderBy('publish_at', 'DESC')
2024-02-27 13:59:16 +01:00
->limit(6)
2024-02-26 10:34:05 +01:00
->with('news')
->get();
$newsModels = News::query()->where('published', true)
->orderBy('publish_at', 'DESC')
->limit(4)
->get();
$slideModels = Slide::query()->where('slider', SliderTypeEnum::home)->get();
2024-03-13 12:28:35 +01:00
$missionSection = $sectionModels->where('section', PageSectionEnum::home_missions)->first();
$ambitionSection = $sectionModels->where('section', PageSectionEnum::home_ambition)->first();
$teamSection = $sectionModels->where('section', PageSectionEnum::home_team)->first();
$lifeSection = $sectionModels->where('section', PageSectionEnum::home_life)->first();
2024-02-26 10:34:05 +01:00
2024-03-13 12:28:35 +01:00
return view('fo.pages.home', compact(
'staticPageModel',
'sectionModels',
'stripModels',
'newsModels',
'slideModels',
'missionSection',
'ambitionSection',
'teamSection',
'lifeSection',
));
2023-11-13 11:56:06 +01:00
}
}