settingsRepo = $settingsRepo; $this->helperService = $helperService; $this->authService = $authService; } /** * @throws BindingResolutionException */ public function with(): array { $action = FrontcontrollerCore::getCurrentRoute(); // Don't show modals in test environment if (app()->environment('testing')) { return ['showHelperModal' => false, 'currentModal' => [], 'isFirstLogin' => false]; } $showHelperModal = false; $completedOnboarding = $this->settingsRepo->getSetting('companysettings.completedOnboarding'); $isFirstLogin = $this->helperService->isFirstLogin($this->authService->getUserId()); // Backwards compatibilty if ($isFirstLogin && $completedOnboarding) { $isFirstLogin = false; } $currentModal = $this->helperService->getHelperModalByRoute($action); if ( $isFirstLogin === false && $currentModal['template'] !== 'notfound' && ( session()->exists('usersettings.modals.'.$currentModal['template']) === false || session('usersettings.modals.'.$currentModal['template']) === false) ) { if (! session()->exists('usersettings.modals')) { session(['usersettings.modals' => []]); } if (! session()->exists('usersettings.modals.'.$currentModal['template'])) { session(['usersettings.modals.'.$currentModal['template'] => 1]); $showHelperModal = true; } } // For development purposes, always show the modal return [ 'completedOnboarding' => $completedOnboarding, 'showHelperModal' => $showHelperModal, 'currentModal' => $currentModal['template'], 'isFirstLogin' => $isFirstLogin, ]; } }