settingsRepo = $settingsRepo; $this->config = $config; $this->appSettings = $appSettings; $this->themeCore = $themeCore; } public function with(): array { // Batch-preload all theme settings in a single query on first load. // This populates SettingCache's in-memory tier so all subsequent // getSetting() calls from getActive(), getColorMode(), etc. are instant. $this->themeCore->preloadUserSettings(); $theme = $this->themeCore->getActive(); $colorMode = $this->themeCore->getColorMode(); $colorScheme = $this->themeCore->getColorScheme(); $themeFont = $this->themeCore->getFont(); // Set colors to use if (! session()->exists('companysettings.sitename')) { $sitename = $this->settingsRepo->getSetting('companysettings.sitename'); if ($sitename !== false) { session(['companysettings.sitename' => $sitename]); } else { session(['companysettings.sitename' => $this->config->sitename]); } } $backgroundOpacity = 0.1; if ($this->themeCore->getBackgroundType() == 'image') { $backgroundOpacity = 1; } return [ 'sitename' => session('companysettings.sitename') ?? '', 'primaryColor' => $this->themeCore->getPrimaryColor(), 'theme' => $theme, 'version' => $this->appSettings->appVersion ?? '', 'themeScripts' => [ $this->themeCore->getJsUrl(), $this->themeCore->getCustomJsUrl(), ], 'themeColorMode' => $colorMode, 'themeColorScheme' => $colorScheme, 'themeFont' => $themeFont, 'themeStyles' => [ [ 'id' => 'themeStyleSheet', 'url' => $this->themeCore->getStyleUrl(), ], [ 'url' => $this->themeCore->getCustomStyleUrl(), ], ], 'accents' => [ $this->themeCore->getPrimaryColor(), $this->themeCore->getSecondaryColor(), false, // accent3 uses CSS default false, // accent4 uses CSS default ], 'themeBg' => $this->themeCore->getBackgroundImage(), 'themeOpacity' => $backgroundOpacity, 'themeType' => $this->themeCore->getBackgroundType(), ]; } }