/** * 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; }
/** * Signs user up. * * @return User|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(); if ($user->save()) { return $user; } } return null; }
/** * 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; }