Example #1
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->status = 0;
         if ($user->save()) {
             $notification = new Notification();
             $notification->title = 'user';
             $notification->message = 'new user, username:'******'model' => 'User', 'id' => $user->id]);
             if ($notification->save()) {
                 $this->sendEmail($this->email);
             } else {
                 print_r($notification->getErrors());
                 exit(0);
             }
             return $user;
         } else {
             return $user->getErrors();
         }
     }
     return null;
 }
Example #2
0
 /**
  * Signs user up.
  *
  * @return Member |null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new Member();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->status = Member::STATUS_ACTIVE;
         if ($user->save()) {
             Yii::$app->session->setFlash('success', 'Well done! successfully to registered data!  ');
             $notification = new Notification();
             $notification->title = 'member';
             $notification->message = 'new member, username:'******'model' => 'Member', 'id' => $user->id]);
             if ($notification->save()) {
                 $this->sendEmail($this->email);
                 Yii::$app->session->setFlash('success', 'please check your email!  ');
             } else {
                 print_r($notification->getErrors());
                 exit(0);
             }
             return $user;
         } else {
             return $user->getErrors();
         }
     }
     return null;
 }
 /**
  * Creates a new Notification model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Notification();
     if ($model->loadWithFiles(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', 'Well done! successfully to save data!  ');
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }