public function get_sent($uuid)
 {
     session_start();
     if (isset($_SESSION["email"]) && !empty($_SESSION["email"])) {
         $messages = $this->dbObject->mGetAllByUserSent($uuid);
         $sent = array();
         $userObject = new UsuariosModel();
         $mascotaObject = new MascotaModel();
         foreach ($messages as $key => $message) {
             $user_uuid = $userObject->getByuuid($message["to"]);
             if ($user_uuid) {
                 $sent[] = array("uuid" => $message["uuid"], "to" => $user_uuid["nombre"], "subject" => $message["subject"], "date" => $message["created_at"]);
             } else {
                 $mascota = $mascotaObject->mMascotaByUUID($message["to"]);
                 if ($mascota) {
                     $sent[] = array("uuid" => $message["uuid"], "to" => $mascota["nombre"], "subject" => $message["subject"], "date" => $message["created_at"]);
                 }
             }
         }
         return View::make("sent", array("uuid" => $uuid, "messages" => $sent));
     } else {
         return Redirect::to("/");
     }
 }
 public function getMyFavs($current_uuid)
 {
     $favs = $this->connection->mMyFavs($current_uuid);
     if (is_array($favs)) {
         //print_r($favs);die;
         $favorito = array();
         $userObject = new UsuariosModel();
         $mascotaObject = new MascotaModel();
         foreach ($favs as $key => $fav) {
             $user_uuid = $userObject->getByuuid($fav["mi_favorito"]);
             if ($user_uuid) {
                 $favorito[] = array("uuid" => $fav["mi_favorito"], "nombre" => $user_uuid["nombre"]);
             } else {
                 $mascota = $mascotaObject->mMascotaByUUID($fav["mi_favorito"]);
                 if ($mascota) {
                     $favorito[] = array("name" => $message["nombre"], "uuid" => $fav["mi_favorito"]);
                 }
             }
         }
         return json_encode(array("status" => 200, "favoritos" => $favorito));
     } else {
         return json_encode(array("status" => 200, "message" => "No tienes favoritos aun"));
     }
 }
 public function get_visita($animalistaUUID)
 {
     session_start();
     if ($animalistaUUID == null) {
         return Redirect::to("/");
     }
     $user = $this->getUserByEmail($_SESSION["email"]);
     $img = new ImageModel();
     $images = $img->mGetByUUId($animalistaUUID);
     $animalistaObject = new AnimalistaModel();
     $profile = $animalistaObject->mGetAnimalistaByUUID($animalistaUUID);
     $user_animalista = new UsuariosModel();
     $name_animalista = $user_animalista->getByuuid($profile["user_uuid"]);
     $profile["nombre"] = $name_animalista["nombre"];
     return View::make("user-visita", array("profile" => $profile, "images" => $images, "user" => $user));
 }
 public function get_mascotaProfile($uuid, $mascotaid)
 {
     session_start();
     try {
         if (isset($_SESSION["email"]) && !empty($_SESSION["email"])) {
             $user = new UsuariosController();
             $userData = $user->getUserByEmail($_SESSION["email"]);
             $mascotaModel = new MascotaModel();
             $mascotaData = $mascotaModel->mMascotaByUUID($mascotaid);
             $img = new ImageModel();
             $images = $img->mGetByUUId($mascotaData["uuid"]);
             $eventObject = new CalendarioModel();
             $events = $eventObject->mGetByUserUUID($mascotaData["uuid"]);
             $msg = new MensajesModel();
             $messages = $msg->mGetAllByUser($mascotaid);
             $inbox = array();
             if ($messages) {
                 $userObject = new UsuariosModel();
                 $mascotaObject = new MascotaModel();
                 foreach ($messages as $key => $message) {
                     $user_uuid = $userObject->getByuuid($message["from"]);
                     if ($user_uuid) {
                         $inbox[] = array("uuid" => $message["uuid"], "from" => $user_uuid["nombre"], "subject" => $message["subject"], "date" => $message["date"]);
                     } else {
                         $mascota = $mascotaObject->mMascotaByUUID($message["from"]);
                         if ($mascota) {
                             $inbox[] = array("uuid" => $message["uuid"], "from" => $mascota["nombre"], "subject" => $message["subject"], "date" => $message["date"]);
                         }
                     }
                 }
             }
             $estados = new EstadosModel();
             $municipios = $estados->get_temp();
             return View::make("mascota-profile", array("user" => $userData, "mascota" => $mascotaData, "images" => $images, "events" => $events, "messages" => $inbox, "municipios" => $municipios));
         } else {
             Auth::logout();
             unset($_SESSION["email"]);
             return Redirect::to("/");
         }
     } catch (exception $e) {
         echo $e;
     }
 }