/**
  * Signs user up.
  *
  * @return Member|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $connection = yii::$app->db;
         $transaction = $connection->beginTransaction();
         $pw = $this->password;
         try {
             $member = new Member();
             $member->email = $this->email;
             $member->setPassword($pw);
             $member->generateAuthKey();
             $member->beforeSave(TRUE);
             $member->save();
             $member_profile = new MemberProfile();
             $member_profile->name = $this->name;
             $member_profile->address = $this->address;
             $member_profile->contact_number = $this->contact_number;
             $member_profile->member_id = $member->id;
             $member_profile->beforeSave(TRUE);
             $member_profile->save();
             if (1 == $this->is_affiliate) {
                 $affiliate = new ApMembers();
                 $affiliate->email = $member->email;
                 $affiliate->fullname = $this->name;
                 $affiliate->balance = '0.00';
                 $affiliate->terms = '1';
                 $affiliate->password = password_hash($pw, PASSWORD_DEFAULT, ["cost" => 10]);
                 $affiliate->admin_user = '******';
                 $affiliate->browser = $_SERVER['HTTP_USER_AGENT'];
                 $affiliate->referrar_id = $this->referrar_id;
                 $affiliate->save();
             }
             $transaction->commit();
             return $member;
         } catch (Exception $exc) {
             $transaction->rollBack();
             throw $e;
         }
     }
     return null;
 }
 public function actionCart_amount()
 {
     $model = MemberProfile::find()->where('member_id = :mid', [':mid' => Yii::$app->user->identity->id])->one();
     if (isset($_POST['MemberProfile']) && !empty($_POST['MemberProfile'])) {
         $model->attributes = $_POST['MemberProfile'];
         $model->beforeSave(false);
         if ($model->validate() && $model->save()) {
             return $this->redirect('profile');
         }
     }
     return $this->render('_form', ['model' => $model]);
 }
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMemberProfiles()
 {
     return $this->hasMany(MemberProfile::className(), ['member_id' => 'id']);
 }