private function updateAjax()
 {
     $data = Yii::$app->request->post();
     $model = Warehouse::findOne(['warehouse_id' => $_GET['id']]);
     if ($model != null) {
         $model->scenario = Warehouse::SCENARIO_UPDATE;
         foreach ($data['Warehouse'] as $key => $value) {
             $model->{$key} = $value;
         }
         if ($model->validate()) {
             return $model->save() ? true : ErrorHelper::errorsToString($model->errors);
         } else {
             return ErrorHelper::errorsToString($model->errors);
         }
     }
 }
예제 #2
0
 private function updateAjax()
 {
     $data = Yii::$app->request->post();
     $model = User::findOne(['user_id' => $_GET['id']]);
     if ($model != null) {
         $model->scenario = User::SCENARIO_UPDATE;
         foreach ($data['User'] as $key => $value) {
             $model->{$key} = $value;
         }
         if ($model->validate()) {
             $model = PasswordHelper::checkPassword($model);
             $model->save();
             return true;
         } else {
             return ErrorHelper::errorsToString($model->errors);
         }
     }
 }