public function addNewUser() { $this->pass = PasswordHelper::hashPassword($this->pass); $this->pass_repeat = PasswordHelper::hashPassword($this->pass_repeat); $this->login = $this->email; $this->user_role = 0; if ($this->validate()) { $this->save(); return true; } else { return false; } }
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); } } }