public function post_createPet()
 {
     $this->data = Input::all();
     if ($this->data["clase_mascota"] == "Mini pig") {
         $this->data["raza"] = "Mini pig";
     }
     $certificados = "";
     $vacunas = "";
     if (is_array($this->data["certificado"])) {
         foreach ($this->data["certificado"] as $key => $certificado) {
             $certificados .= $certificado . ", ";
         }
         $this->data["certificado"] = $certificados;
     } else {
         $this->data["certificado"] = "No tiene";
     }
     if (is_array($this->data["vacunas_cuales"])) {
         foreach ($this->data["vacunas_cuales"] as $key => $vacuna) {
             $vacunas .= $vacuna . ", ";
         }
         $this->data["vacunas_cuales"] = $vacunas;
     } else {
         $this->data["vacunas_cuales"] = "No tiene";
     }
     //print_r($this->data);die;
     //$this->data["raza"] = empty($this->data["perro"]) ? $this->data["gato"] : $this->data["perro"];
     //list($mes, $dia, $anio) = preg_split('/\//', $this->data["fecha_nacimiento"]);
     //$this->data["fecha_nacimiento"] = strtotime($dia."-".$mes."-".$anio);
     $this->data["uuid"] = UUID::getUUID();
     if ($this->connection->mSave($this->data)) {
         return json_encode(array("message" => "Mascota creada", "type" => 201, "error" => 0, "uuid" => $this->data["uuid"]));
     } else {
         return json_encode(array("message" => "Error al crear mascota", "type" => 500, "error" => 1));
     }
 }
 public function mSave($fav)
 {
     if (is_array($fav)) {
         $fav = (object) $fav;
     }
     try {
         $this->fav_uuid = UUID::getUUID();
         $this->mi_favorito_uuid = $fav->profile;
         $this->usuario_actual = $fav->me;
         return $this->save();
     } catch (exception $e) {
         echo $e;
         die;
     }
 }
 public function mSave($image)
 {
     try {
         if (is_array($image)) {
             $image = (object) $image;
         }
         $this->image_uuid = UUID::getUUID();
         $this->user_uuid = $image->user_uuid;
         $this->is_profile = $image->is_profile;
         $this->path = $image->path;
         return $this->save();
     } catch (exception $e) {
         return 0;
     }
 }
 public function mSave($beneficio)
 {
     try {
         if (is_array($beneficio)) {
             $beneficio = (object) $beneficio;
         }
         $this->beneficio_uuid = UUID::getUUID();
         $this->user_uuid = $beneficio->user_uuid;
         $this->mascota_uuid = $beneficio->mascota_uuid;
         $this->nombre_beneficio = $beneficio->nombre_beneficio;
         $this->descripcion = $beneficio->descripcion;
         $this->confirmacion = $beneficio->confirmacion;
         $this->categoria = $beneficio->categoria;
         return $this->save();
     } catch (exception $e) {
         echo $e;
     }
 }
 public function mSave($message)
 {
     try {
         if (is_array($message)) {
             $message = (object) $message;
         }
         $this->mensajes_uuid = UUID::getUUID();
         $this->from_uuid = $message->from;
         $this->to_uuid = $message->to;
         $this->subject = $message->subject;
         $this->body = $message->body;
         $this->is_read = 0;
         $this->sent = $message->sent;
         return $this->save();
     } catch (exception $e) {
         echo $e;
     }
 }
 public function mSave($calendar)
 {
     try {
         if (is_array($calendar)) {
             $calendar = (object) $calendar;
         }
         $this->calendario_uuid = UUID::getUUID();
         $this->nombre_evento = $calendar->nombre_evento;
         $this->descripcion_evento = $calendar->descripcion_evento;
         $this->fecha_evento = $calendar->fecha_evento;
         $this->usuario_uuid = $calendar->user;
         if ($this->save()) {
             return 1;
         } else {
             return 0;
         }
     } catch (exception $e) {
         echo $e;
         return 0;
     }
 }
 public function mSave($user)
 {
     try {
         if (is_array($user)) {
             $user = (object) $user;
         }
         $this->UUID_usuarios = $user->UUID;
         $this->nombre = $user->nombre;
         $this->password = Hash::make($user->password);
         $this->text_password = $user->password;
         $this->email = $user->email;
         $this->status = 0;
         $this->payment = 0;
         $this->activated_uuid = UUID::getUUID();
         if ($this->save()) {
             return 1;
         } else {
             return 0;
         }
     } catch (exception $e) {
         return $this->JSONResponse(1, $e);
     }
 }
 public function post_register()
 {
     session_start();
     $this->data = Input::all();
     $emailExist = $this->connection->mVerifyEmail($this->data["email"]);
     try {
         if (!$emailExist) {
             $this->data["UUID"] = UUID::getUUID();
             if ($this->connection->mSave($this->data)) {
                 //logea al usuario despues de ser registrado
                 $user = $this->connection->mUserByEmail($this->data["email"]);
                 //print_r($user);die;
                 //print_r($this->data);die;
                 try {
                     $client = new Client();
                     $r = $client->post('http://dev.petmatch.club/email.php', ["body" => $this->data]);
                     $r->getBody();
                 } catch (exception $e) {
                     echo $e;
                 }
                 //$email = new Email();
                 //$email->sendEmail($this->data["email"],$this->data["nombre"]);
                 /*$credentials = array(
                       "email" => $this->data["email"],
                       "password" => $this->data["password"]
                   );
                   if (Auth::attempt($credentials)) {
                       $_SESSION["email"] = $this->data["email"];
                   }*/
                 return HTTPResponse::response(0, 201);
             }
         } else {
             return json_encode(array("error" => 1, "message" => $this->data["email"] . " ya existe", "status" => 200));
         }
     } catch (exception $e) {
         echo HTTPResponse::response(1, 500);
     }
 }