Beispiel #1
0
 /**
  * Updates an existing AliasUrl model.
  * If update is successful, the browser will be redirected to the 'view' page.
  *
  * @param string $id
  *
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if (isset($_POST['AliasUrl'])) {
         $post = $_POST['AliasUrl'];
         $public = strtolower(trim($post['public']));
         if (AppAliasUrl::isDuplicate($id, $public, $post['is_frontend']) == TRUE) {
             Alerts::setAlertType(Alerts::ALERT_WARNING);
             Alerts::setMessage('Public alias already taken');
         } else {
             CoreHelper::saveModelForm('c006\\url\\models\\AliasUrl', $post);
             Alerts::setAlertType(Alerts::ALERT_SUCCESS);
             Alerts::setMessage('SUCCESS: Information updated');
         }
         return $this->redirect('/alias');
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
 /**
  *
  */
 function init()
 {
     if (CoreHelper::checkLogin() && CoreHelper::isGuest()) {
         return $this->redirect('/');
     }
 }
 /**
  * @param string $migration
  *
  * @return int
  */
 public function actionUp($migration = '')
 {
     if (empty($migration)) {
         $this->stdout("No new migration found. Your system is up-to-date.\n", Console::FG_GREEN);
         return self::EXIT_CODE_NORMAL;
     }
     /* ~ C006 */
     $base = str_replace('\\console', '', Yii::$app->basePath) . '/vendor';
     $array = CoreHelper::recursiveDirectory($base, $base);
     foreach ($array as $vendor) {
         $vendor = $vendor['item'];
         if ($vendor['is_dir'] && isset($vendor['sub_folders']) && sizeof($vendor['sub_folders'])) {
             //$this->stdout($vendor['folder'] . "\n", Console::FG_RED);
             foreach ($vendor['sub_folders'] as $extension) {
                 $extension = $extension['item'];
                 if ($extension['is_dir'] && isset($extension['sub_folders']) && sizeof($extension['sub_folders'])) {
                     foreach ($extension['sub_folders'] as $folder) {
                         $folder = $folder['item'];
                         if ($folder['is_dir'] && $folder['folder'] == "migrations") {
                             if (isset($folder['sub_folders']) && sizeof($folder['sub_folders'])) {
                                 foreach ($folder['sub_folders'] as $file) {
                                     $file = $file['item'];
                                     if ($file['file'] == $migration . '.php') {
                                         $this->migrationPath = CoreHelper::cleanSlashInPath($file['path'], FALSE);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->stdout("\t{$migration}\n");
     $this->stdout("\n");
     if ($this->auto_override || $this->confirm("Run: ", FALSE)) {
         if (!$this->migrateUp($migration)) {
             $this->stdout("\nMigration failed.\n", Console::FG_RED);
             return self::EXIT_CODE_ERROR;
         }
         $this->stdout("\nMigrated up successfully.\n", Console::FG_GREEN);
     } else {
         $this->stdout("\nBye.\n", Console::FG_GREEN);
     }
 }