Пример #1
0
 /**
  * Signs company up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signupCompany()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->name;
         $user->email = $this->email;
         $user->phone = $this->phone;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $check_user = $user->save();
         $service = new Service();
         $service->category_id = $this->category_id;
         $service->owner = $user->id;
         $service->name = $this->name;
         $service->phone = $this->phone;
         $service->description = $this->description;
         $check_service = $service->save();
         if ($check_user && $check_service) {
             return $user;
         }
         VarDumper::dump($service->getErrors(), 6, 1);
         die;
     }
     return null;
 }