ldc-legaulois/app/Http/Controllers/Fo/StaticPageController.php

135 lines
4.8 KiB
PHP
Raw Normal View History

2024-01-10 14:49:46 +01:00
<?php
namespace App\Http\Controllers\Fo;
2024-07-17 09:44:08 +02:00
use App\Enums\Settings\SettingsType;
2024-01-10 14:49:46 +01:00
use App\Enums\StaticPageType;
use App\Http\Controllers\Controller;
2024-03-29 09:38:01 +01:00
use App\Models\BrandAdvantage;
2024-07-17 09:44:08 +02:00
use App\Models\GeneralSetting;
use App\Models\HistoricalMilestone;
use App\Models\KeyNumber;
use App\Models\NewsCorporate;
use App\Models\Offer;
2024-03-27 18:32:30 +01:00
use App\Models\Profession;
2024-01-10 14:49:46 +01:00
use App\Models\StaticPage;
use App\Models\Testimonial;
2024-05-14 15:16:35 +02:00
use App\Models\Video;
use Illuminate\Support\Facades\Cache;
use Detection\MobileDetect;
2024-01-10 14:49:46 +01:00
class StaticPageController extends Controller
{
/**
2024-03-27 17:16:14 +01:00
* Legals page.
2024-01-10 14:49:46 +01:00
*
2024-03-27 17:16:14 +01:00
* @param \App\Models\StaticPage $staticPageModel
2024-01-10 14:49:46 +01:00
* @return \Illuminate\Contracts\View\View
*/
2024-05-16 14:06:45 +02:00
public function legals(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
2024-01-10 14:49:46 +01:00
{
$staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::legals);
2024-03-27 17:16:14 +01:00
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
2024-01-10 14:49:46 +01:00
}
/**
2024-03-27 17:16:14 +01:00
* Confidentiality page.
2024-01-10 14:49:46 +01:00
*
2024-03-27 17:16:14 +01:00
* @param \App\Models\StaticPage $staticPageModel
2024-01-10 14:49:46 +01:00
* @return \Illuminate\Contracts\View\View
*/
2024-05-16 14:06:45 +02:00
public function policies(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
2024-01-10 14:49:46 +01:00
{
$staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::confidentiality);
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
}
/**
* Termes and conditions selling page.
*
* @param \App\Models\StaticPage $staticPageModel
* @return \Illuminate\Contracts\View\View
*/
public function selling(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
$staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::selling);
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
}
/**
* Accessibility page.
*
* @param \App\Models\StaticPage $staticPageModel
* @return \Illuminate\Contracts\View\View
*/
public function accessibility(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
$staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::accessibility);
2024-03-27 17:16:14 +01:00
return view('fo.pages.legals', ['staticPageModel' => $staticPageModel]);
}
/**
* Recruitment page.
*
* @param \App\Models\StaticPage $staticPageModel
* @return \Illuminate\Contracts\View\View
*/
2024-05-16 14:06:45 +02:00
public function recruitment(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
2024-03-27 17:16:14 +01:00
{
$detect = new MobileDetect();
$staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::recruitment);
$offerModels = Cache::rememberForever(
2024-07-17 09:44:08 +02:00
config('services.digital_recruiter.url'),
fn() => Offer::query()->where('published', true)->orderBy('publish_at', 'DESC')->take(6)->get()
2024-07-17 09:44:08 +02:00
);
$professionModels = Profession::getRandomPublished();
$brandAdvantageModels = BrandAdvantage::getPublishedOrdered();
$newsCorporateModels = NewsCorporate::get9PublishedOrderedByUpdatedAt();
if ($detect->isMobile()) {
$newsCorporateModels = $newsCorporateModels->take(3);
}
2024-07-17 09:44:08 +02:00
$digitalRecruiterCount = Cache::rememberForever(
sprintf('%s-count', config('services.digital_recruiter.url')),
fn() => GeneralSetting::query()->where('type', SettingsType::offersCount)->firstOrFail()->value['count']
2024-07-17 09:44:08 +02:00
);
$testimonialModels = Testimonial::getPublishedOrdered();
return view('fo.pages.recruitment', compact(
'staticPageModel',
'offerModels',
'professionModels',
2024-07-17 09:44:08 +02:00
'brandAdvantageModels',
'digitalRecruiterCount',
'testimonialModels',
'newsCorporateModels',
'detect'
));
2024-01-10 14:49:46 +01:00
}
/**
* Who are we page.
*
* @param \App\Models\StaticPage $staticPageModel
* @return \Illuminate\Contracts\View\View
*/
2024-05-16 14:06:45 +02:00
public function story(StaticPage $staticPageModel): \Illuminate\Contracts\View\View
{
$staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::story);
$keyNumberModels = KeyNumber::get5PublishedOrdered();
2024-09-27 11:02:56 +02:00
$historicalMilestoneModels = HistoricalMilestone::getPublishedOrdered();
return view('fo.pages.story', compact('staticPageModel', 'keyNumberModels', 'historicalMilestoneModels'));
}
2024-05-14 15:16:35 +02:00
/**
* Advertising saga page.
*
* @param \App\Models\StaticPage $staticPageModel
* @return \Illuminate\Contracts\View\View
*/
public function saga(StaticPage $staticPageModel)
{
$staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::saga);
$videoModels = Video::get6PublishedVideosOrderedWithProducts();
2024-05-14 15:16:35 +02:00
return view('fo.pages.saga', compact('staticPageModel', 'videoModels'));
}
2024-01-10 14:49:46 +01:00
}