Пример #1
0
 /**
  * Creates a new Members model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Members();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #2
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new Members();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->display_name = $this->display_name;
         $user->generateAuthKey();
         $user->role_id = '2';
         $user->avatar = 'uploads/default.jpg';
         $user->status = '10';
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }