setPassword() public method

Generates password hash from password and sets it to the model
public setPassword ( string $password )
$password string
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new Admin();
         $user->fname = $this->fname;
         $user->lname = $this->lname;
         $user->contact_no = $this->contact_no;
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->company_name = $this->company_name;
         $user->company_description = $this->company_description;
         $user->shipping_address = $this->shipping_address;
         $user->generateAuthKey();
         $user1 = new User();
         $user1->fname = $this->fname;
         $user1->lname = $this->lname;
         $user1->contact_no = $this->contact_no;
         $user1->username = $this->username;
         $user1->email = $this->email;
         $user1->setPassword($this->password);
         $user1->company_name = $this->company_name;
         $user1->company_description = $this->company_description;
         $user1->shipping_address = $this->shipping_address;
         $user1->generateAuthKey();
         if ($user->save() && $user1->save()) {
             return $user;
             return $user1;
         }
     }
     return null;
 }
Example #2
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new Admin();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }