/** * Allow turn on/off widget * @param string $controllerName * @return string * @throws \Ffcms\Core\Exception\NativeException * @throws ForbiddenException * @throws \Ffcms\Core\Exception\SyntaxException */ public function actionTurn($controllerName) { // get controller name & find object in db $controllerName = ucfirst(Str::lowerCase($controllerName)); $record = \Apps\ActiveRecord\App::where('sys_name', '=', $controllerName)->where('type', '=', 'widget')->first(); // check if widget admin controller exists if ($record === null || (int) $record->id < 1) { throw new ForbiddenException('Widget is not founded'); } // initialize turn on/off model $model = new FormTurn($record); if ($model->send()) { $model->update(); App::$Session->getFlashBag()->add('success', __('Widget status was changed')); } // render view return $this->view->render('turn', ['widget' => $record, 'model' => $model]); }
/** * Allow turn on/off applications * @param $controllerName * @return string * @throws \Ffcms\Core\Exception\NativeException * @throws ForbiddenException * @throws \Ffcms\Core\Exception\SyntaxException */ public function actionTurn($controllerName) { $controllerName = ucfirst(Str::lowerCase($controllerName)); $search = \Apps\ActiveRecord\App::where('sys_name', '=', $controllerName)->where('type', '=', 'app')->first(); if ($search === null || (int) $search->id < 1) { throw new ForbiddenException('App is not founded'); } $model = new FormTurn($search); if ($model->send()) { $model->update(); App::$Session->getFlashBag()->add('success', __('Application status was changed')); } return $this->view->render('turn', ['app' => $search, 'model' => $model]); }