Example #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]);
     }
 }