ldc-volena/app/Providers/ViewServiceProvider.php

94 lines
4.6 KiB
PHP
Raw Normal View History

2023-11-13 11:56:06 +01:00
<?php
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
2025-02-27 16:43:22 +01:00
use App\Enums\StaticPageType;
use App\Enums\Slides\SliderTypeEnum;
use App\Models\StaticPage;
use App\Models\Section;
2023-11-13 11:56:06 +01:00
class ViewServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(): void
{
$appInfos = Cache::remember('composer', 360, function () {
return json_decode(File::get(\app_path('../composer.json')));
});
// Share composer.json infos.
if (isset($appInfos->name) and isset($appInfos->version)) {
View::share('cpsr_name', $appInfos->name);
View::share('cpsr_version', $appInfos->version);
}
if (!app()->runningInConsole()) {
// * FORCE BOOTSTRAP PAGINATOR (or custom if in front)
// Early boot, request wont be filled as expected.
if (collect(explode('/', \request()->getPathInfo()))->get(1) === 'bo') {
Paginator::defaultView('bo.modules.pagination');
} else {
Paginator::useBootstrapFive();
}
2025-02-27 16:43:22 +01:00
collect([
['name' => 'homeStaticPageModel', 'value' => StaticPage::getStaticPage(StaticPageType::home)],
['name' => 'veilStaticPageModel', 'value' => StaticPage::getStaticPage(StaticPageType::unveil)],
['name' => 'hireStaticPageModel', 'value' => StaticPage::getStaticPage(StaticPageType::we_hire)],
['name' => 'commitStaticPageModel', 'value' => StaticPage::getStaticPage(StaticPageType::we_commit)],
['name' => 'moveStaticPageModel', 'value' => StaticPage::getStaticPage(StaticPageType::we_move)],
['name' => 'produceStaticPageModel', 'value' => StaticPage::getStaticPage(StaticPageType::we_produce)],
['name' => 'listenStaticPageModel', 'value' => StaticPage::getStaticPage(StaticPageType::we_listen)],
2025-05-06 17:16:49 +02:00
[
'name' => 'confidentialityStaticPageModel',
'value' => StaticPage::getStaticPage(StaticPageType::confidentiality)
],
['name' => 'legalsStaticPageModel', 'value' => StaticPage::getStaticPage(StaticPageType::legals)],
// * HOME SECTIONS
['name' => 'homeSections', 'value' => Section::getSections(StaticPageType::home)],
// * UNVEIL SECTION
['name' => 'veilSections', 'value' => Section::getSections(StaticPageType::unveil)],
// * WE HIRE SECTION
['name' => 'hireSections', 'value' => Section::getSections(StaticPageType::we_hire)],
// * WE COMMIT SECTION
['name' => 'commitSections', 'value' => Section::getSections(StaticPageType::we_commit)],
// * WE MOVE SECTION
['name' => 'moveSections', 'value' => Section::getSections(StaticPageType::we_move)],
// * WE PRODUCE SECTION
['name' => 'produceSections', 'value' => Section::getSections(StaticPageType::we_produce)],
// * WE LISTEN SECTION
['name' => 'listenSections', 'value' => Section::getSections(StaticPageType::we_listen)],
// * RESPECT HEARTH SLIDE
['name' => 'respectSlides', 'value' => SliderTypeEnum::respect_earth],
2025-02-27 16:43:22 +01:00
])->map(function ($array) {
View::share($array['name'], (function () use ($array) {
return $array['value'] ?: null;
})());
});
// * HOME ACTIVE SECTIONS
View::share('isActiveHome', Section::isActive(StaticPageType::home));
// * UNVEIL ACTIVE SECTIONS
View::share('isActiveVeil', Section::isActive(StaticPageType::unveil));
// * UNVEIL ACTIVE SECTIONS
View::share('isActiveHire', Section::isActive(StaticPageType::we_hire));
// * WE HIRE ACTIVE SECTIONS
View::share('isActiveCommit', Section::isActive(StaticPageType::we_commit));
// * WE COMMIT ACTIVE SECTIONS
View::share('isActiveMove', Section::isActive(StaticPageType::we_move));
// * WE PRODUCE ACTIVE SECTIONS
View::share('isActiveProduce', Section::isActive(StaticPageType::we_produce));
// * WE LISTEN ACTIVE SECTIONS
View::share('isActiveListen', Section::isActive(StaticPageType::we_listen));
} //end if
2023-11-13 11:56:06 +01:00
}
}