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::query()->whereIn('type', StaticPageType::getBreedingPages())->get(); })()); // * Inject configuration model collect([ ['name' => 'mainMenuSettingModel', 'enum' => SettingsType::mainMenu], ['name' => 'hotNewsSettingModel', 'enum' => SettingsType::hotNews], ['name' => 'breederMapComponentSettingModel', 'enum' => SettingsType::breederMapComponent], ])->map(function ($array) { View::share($array['name'], (function () use ($array) { return GeneralSetting::query()->where('type', $array['enum'])->first() ?: null; })()); }); // * Inject some data for the bo menu. collect([ ['name' => 'customerModelsCount', 'value' => Customer::query()->count()], ['name' => 'firstMeat', 'value' => Meat::query()->first()], ['name' => 'firstRange', 'value' => Range::query()->first()], ['name' => 'mainMenuRangeModels', 'value' => Range::query()->orderBy('order', 'ASC') ->where('published', true)->get()], ['name' => 'mainMenuMeatModels', 'value' => Meat::query()->orderBy('order', 'ASC') ->where('published', true)->get()], ['name' => 'homeStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::home)->first()], ['name' => 'storyStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::story)->first()], ['name' => 'recruitmentStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::recruitment)->first()], ['name' => 'sagaStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::saga)->first()], ['name' => 'recipesStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::recipes)->first()], ['name' => 'recipeStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::recipe)->first()], ['name' => 'productsStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::products)->first()], ['name' => 'legalsStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::legals)->first()], ['name' => 'confidentialityStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::confidentiality)->first()], ['name' => 'sellingStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::selling)->first()], ['name' => 'accessibilityStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::accessibility)->first()], ['name' => 'productStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::product)->first()], ['name' => 'breedingPoultryStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::breedingPoultry)->first()], ['name' => 'breedingJobStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::breedingJob)->first()], ['name' => 'breedingFoodStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::breedingFood)->first()], ['name' => 'breedingHealthStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::breedingHealth)->first()], ['name' => 'newsStaticPageModel', 'value' => StaticPage::query() ->where('type', StaticPageType::news)->first()], ])->map(function ($array) { View::share($array['name'], (function () use ($array) { return $array['value'] ?: null; })()); }); } //end if } }