Beispiel #1
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new Customer();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }
Beispiel #2
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getCustomer()
 {
     if ($this->_customer === false) {
         $this->_customer = Customer::findByUsername($this->username);
     }
     return $this->_customer;
 }
Beispiel #3
0
 /**
  * 一对一
  */
 public function getCustomer()
 {
     return $this->hasOne(Customer::className(), ['id' => 'customer_id']);
 }