Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 3
0
 /**
  * 一对一
  */
 public function getCustomer()
 {
     return $this->hasOne(Customer::className(), ['id' => 'customer_id']);
 }