public static function getAvailableMaxBorrowAmount() { $max = 0; $type = User::find()->select('type')->where(['id' => \Yii::$app->user->getId()])->one(); if ($type->type == REGISTER_AS_INDIVIDUAL) { $max = REGISTER_AS_INDIVIDUAL_MAXLIMIT; } elseif ($type->type == REGISTER_AS_COMPANY) { $max = REGISTER_AS_COMPANY_MAXLIMIT; } return $max; }
public function actionDelete() { if (Yii::$app->request->isAjax) { $id = $_POST['id']; $model = User::find()->innerJoinWith('userDetail')->onCondition(['users.id' => $id])->one(); if (isset($model) && !empty($model)) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return $model->delete($id) && UserDetail::deleteAll(['user_id' => $id]) ? ['status' => 'success', 'recordDeleted' => DELETED] : ['status' => 'failure']; } } }
/** * Function to create unique username */ public function generateUsername() { if ($username = $this->first_name) { $i = 1; do { $username = strtolower($this->first_name . $i); $i++; } while (User::find()->where(["username" => $username])->one()); return $username; } }