*/ public function share(Request $request): array { try { DB::connection()->getPdo(); } catch (\Throwable $th) { return []; } $user = Auth::user(); $system = app('system_settings'); $cartCount = $user ? $this->studentService->getCartCount() : 0; if (Schema::hasTable('languages')) { $langs = Language::where('is_active', true)->orderBy('is_default', 'desc')->get(); $default = $langs->where('is_default', true)->first()->code; config(['app.locale' => $default]); $locale = Cookie::get('locale', $default); App::setLocale($locale); $this->languageService->setLanguageProperties($locale); } else { $langs = []; $locale = Cookie::get('locale', 'en'); } $direction = Cookie::get('direction', 'ltr'); if ($system && array_key_exists('direction', $system->fields)) { $systemDirection = $system->fields['direction']; if ($systemDirection !== 'none') { $direction = $systemDirection; } } return [ ...parent::share($request), 'page' => app('intro_page'), 'auth' => ['user' => $user], 'system' => $system, 'customize' => $request->query('customize', false), 'navbar' => $this->settingsService->getNavbar('navbar_1'), 'footer' => $this->settingsService->getFooter('footer_1'), 'notifications' => $user ? $this->notificationService->notifications(['unread' => true]) : [], 'ziggy' => fn(): array => [ ...(new Ziggy)->toArray(), 'location' => $request->url(), ], 'flash' => [ 'error' => fn() => $request->session()->get('error'), 'warning' => fn() => $request->session()->get('warning'), 'success' => fn() => $request->session()->get('success'), ], 'langs' => $langs, 'locale' => $locale, 'direction' => $direction, 'cartCount' => $cartCount, 'translate' => [ 'auth' => trans('auth'), 'button' => trans('button'), 'common' => trans('common'), 'dashboard' => trans('dashboard'), 'frontend' => trans('frontend'), 'input' => trans('input'), 'settings' => trans('settings'), 'table' => trans('table'), ], ]; } }