예제 #1
0
 public function saveUser(User $user)
 {
     $bcrypt = new Bcrypt();
     $securePass = $bcrypt->create($user->getPassword());
     $data = array('email' => $user->getEmail(), 'first_name' => $user->getFirstName(), 'last_name' => $user->getLastName(), 'password' => $securePass, 'status' => $user->getStatus());
     $idUser = (int) $user->getIdUser();
     if (empty($idUser)) {
         return $this->insert($data);
     } else {
         if ($this->getUser($idUser)) {
             $this->update($data, array('iduser' => $idUser));
         } else {
             throw new \Exception('Usuario não encontrado');
         }
     }
 }