72 lines
3.6 KiB
PHP
72 lines
3.6 KiB
PHP
<?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;
|
|
use App\Enums\StaticPageType;
|
|
use App\Http\Controllers\Bo\StaticPageController;
|
|
use App\Http\Controllers\Bo\SectionController;
|
|
|
|
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();
|
|
}
|
|
|
|
collect([
|
|
['name' => 'homeStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::home)],
|
|
['name' => 'veilStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::unveil)],
|
|
['name' => 'hireStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_hire)],
|
|
['name' => 'commitStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_commit)],
|
|
['name' => 'moveStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_move)],
|
|
['name' => 'produceStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_produce)],
|
|
['name' => 'listenStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_listen)],
|
|
['name' => 'confidentialityStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::confidentiality)],
|
|
['name' => 'legalsStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::legals)],
|
|
/* HOME SECTIONS */
|
|
['name' => 'homeSections', 'value' => SectionController::getSections([1, 2, 3, 4])],
|
|
/* UNVEIL SECTION */
|
|
['name' => 'veilSections', 'value' => SectionController::getSections([5, 6, 7, 8, 9, 10])],
|
|
/* WE HIRE SECTION */
|
|
['name' => 'hireSections', 'value' => SectionController::getSections([11, 12, 13, 14, 15])],
|
|
/* WE COMMIT SECTION */
|
|
['name' => 'commitSections', 'value' => SectionController::getSections([16, 17, 18, 19, 20, 21])],
|
|
/* WE MOVE SECTION */
|
|
['name' => 'moveSections', 'value' => SectionController::getSections([22, 23])],
|
|
/* WE PRODUCE SECTION */
|
|
['name' => 'produceSections', 'value' => SectionController::getSections([24, 25, 26, 27, 28, 29])],
|
|
/* WE LISTEN SECTION */
|
|
['name' => 'listenSections', 'value' => SectionController::getSections([30])],
|
|
])->map(function ($array) {
|
|
View::share($array['name'], (function () use ($array) {
|
|
return $array['value'] ?: null;
|
|
})());
|
|
});
|
|
}
|
|
}
|
|
}
|