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. switch (collect(explode('/', \request()->getPathInfo()))->get(1)) { case 'bo': Paginator::defaultView('bo.modules.pagination'); break; case 'club': Paginator::defaultView('club.modules.pagination'); break; default: Paginator::useBootstrapFive(); break; } // * Inject actual view name View::composer('*', function ($view) { $view->with('viewName', $view->getName()); }); Blade::directive('money', function (string $amountVariable) { // phpcs:ignore Generic.Files.LineLength.TooLong return "format(new Money({$amountVariable} * 100, app('phpMoneyCurrency')))); ?>"; }); // * Inject menuNodeList View::share('menuNodeList', (function () { /** @var \Illuminate\Database\Eloquent\Collection */ $settings = app('settings'); $mainMenu = $settings->where('type', SettingsType::mainMenu)->first(); if (!$mainMenu) { throw new \RuntimeException('Missing setting ' . SettingsType::mainMenu->label()); } return $mainMenu->value; })()); View::share('menuNodeDataList', app('menuNodeDataList')); // * Inject breeding pages for the fo menu. View::share('breedingPages', (function () { /** @var \Illuminate\Database\Eloquent\Collection */ $settings = app('settings'); $mainMenu = $settings->where('type', SettingsType::mainMenu)->first(); if (!$mainMenu) { throw new \RuntimeException('Missing setting ' . SettingsType::mainMenu->label()); } return StaticPage::getCachedBreedingStaticPages(); })()); // * Inject configuration model collect([ ['name' => 'mainMenuSettingModel', 'enum' => SettingsType::mainMenu], ['name' => 'hotNewsSettingModel', 'enum' => SettingsType::hotNews], ['name' => 'breederMapSettingModel', 'enum' => SettingsType::breederMap], ])->map(function ($array) { View::share($array['name'], (function () use ($array) { return GeneralSetting::getCachedGeneralSetting($array['enum']) ?: null; })()); }); // * Inject some data for the bo menu. $customerModelsCount = Cache::remember('customerModelsCount', 86400, function () { return Customer::query()->count(); }); $firstMeat = Cache::remember('firstMeat', 86400, function () { return Meat::query()->first(); }); $firstRange = Cache::remember('firstRange', 86400, function () { return Range::query()->first(); }); // @phpcs:disable Generic.Files.LineLength.TooLong collect([ ['name' => 'customerModelsCount', 'value' => $customerModelsCount], ['name' => 'firstMeat', 'value' => $firstMeat], ['name' => 'firstRange', 'value' => $firstRange], ['name' => 'mainMenuRangeModels', 'value' => Range::getPublishedOrdered()], ['name' => 'mainMenuMeatModels', 'value' => Meat::getPublishedOrdered()], ['name' => 'homeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::home)], ['name' => 'storyStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::story)], ['name' => 'recruitmentStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recruitment)], ['name' => 'sagaStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::saga)], ['name' => 'recipesStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipes)], ['name' => 'recipeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipe)], ['name' => 'productsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::products)], ['name' => 'legalsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::legals)], ['name' => 'confidentialityStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::confidentiality)], ['name' => 'sellingStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::selling)], ['name' => 'accessibilityStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::accessibility)], ['name' => 'sitemapStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::sitemap)], ['name' => 'rulesStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::rules)], ['name' => 'contactStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::contact)], ['name' => 'productStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::product)], ['name' => 'breedingPoultryStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingPoultry)], ['name' => 'breedingJobStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingJob)], ['name' => 'breedingFoodStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingFood)], ['name' => 'breedingHealthStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingHealth)], ['name' => 'newsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::news)], ['name' => 'searchStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::search)], ['name' => 'exitOutsideStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::exitOutside)], ['name' => 'ouiCestBonStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::ouiCBon)], ['name' => 'ourFarmsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::ourFarms)], ['name' => 'tdfStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::tdf)], ])->map(function ($array) { View::share($array['name'], (function () use ($array) { return $array['value'] ?: null; })()); }); // phpcs:enable } //end if } }