Example #1
0
 public function uploadProfileImage(Request $request)
 {
     $destinationPath = public_path() . "/imagesUploaded";
     $file = $request->file('profileImage');
     $extension = $file->getClientOriginalExtension();
     $fileName = rand(111111, 999999) . "." . $extension;
     $upload_success = $file->move($destinationPath, $fileName);
     if ($upload_success) {
         if ($request->has('habitacion')) {
             $foto = ["nombre" => $fileName, "url" => $destinationPath . "/", "idhabitacion" => $request->habitacion];
             $galeria = new galeriaHabitacion();
         } else {
             $foto = ["nombre" => $fileName, "url" => $destinationPath . "/", "identidad" => Session::get('idEnt')];
             $galeria = new galeria();
         }
         //------------------------------------------------------------
         if ($galeria->agregarFoto($foto)) {
             $fotoID = $galeria->getFotoID($fileName);
             //Vuelvo a desviar, no lo pude hacer arriba...
             if ($request->has('habitacion')) {
                 $habitacion = habitacion::where('id', $request->habitacion)->update(['imagen' => $fileName]);
                 $message = "¡Imagen principal de la habitacion modificada con exito!";
             } else {
                 $entidadTuristica = entidadTuristica::where('rif', Session::get("idEnt"))->update(['imagen' => $fileName]);
                 $message = "¡Imagen de perfil agregada con exito!";
             }
             return Response::json(['data' => "Imagen agregada con exito!", 'message' => $message, 'nombreFoto' => $fileName, 'idFotoPerfil' => $fotoID], 200);
         } else {
             return Response::json(['data' => "Error al guardar la imagen!"], 400);
         }
     } else {
         return Response::json('Error Something goes wrong!!!!', 400);
     }
 }
Example #2
0
 public function getInfo(Request $request, $id)
 {
     $servs = new servicios();
     $hotel = entidadTuristica::where('rif', $id)->first();
     $fotos = $hotel->galeria;
     $servicios = (array) $hotel->servicios['attributes'];
     $array_keys = array_keys($servicios);
     unset($array_keys[12]);
     $nombreFotos = $servs->nombreFotos();
     $nombres = $servs->nombres();
     $valoraciones = valoracion::where('identidad', $id)->orderBy('created_at', 'DESC')->get();
     $galeria = new galeria();
     if ($hotel->imagen != null) {
         $idFotoPerfil = $galeria->getFotoID($hotel->imagen);
     } else {
         $idFotoPerfil = null;
     }
     $respuesta = ['hotel' => $hotel, 'fotos' => $fotos, 'servicios' => $servicios, 'array_keys' => $array_keys, 'nombres' => $nombres, 'nombreFotos' => $nombreFotos, 'idFotoPerfil' => $idFotoPerfil, 'valoraciones' => $valoraciones];
     $view = View::make('adminSuper.info')->with($respuesta);
     if ($request->ajax()) {
         $sections = $view->renderSections();
         $response = Response::json(['success' => true, 'data' => $sections['info']], 200);
     } else {
         $response = $view;
     }
     return $response;
 }
Example #3
0
 public function getHotel(Request $request)
 {
     $servs = new servicios();
     $hotel = entidadTuristica::where('rif', Session::get("idEnt"))->first();
     $fotos = $hotel->galeria;
     $servicios = (array) $hotel->servicios['attributes'];
     $array_keys = array_keys($servicios);
     unset($array_keys[12]);
     $nombreFotos = $servs->nombreFotos();
     $nombres = $servs->nombres();
     $galeria = new galeria();
     if ($hotel->imagen != null) {
         $idFotoPerfil = $galeria->getFotoID($hotel->imagen);
     } else {
         $idFotoPerfil = null;
     }
     $respuesta = ['hotel' => $hotel, 'fotos' => $fotos, 'servicios' => $servicios, 'array_keys' => $array_keys, 'nombres' => $nombres, 'nombreFotos' => $nombreFotos, 'idFotoPerfil' => $idFotoPerfil];
     $view = View::make('adminHotel.hotel')->with($respuesta);
     if ($request->ajax()) {
         $sections = $view->renderSections();
         $response = Response::json(['success' => true, 'data' => $sections['hotel']], 200);
     } else {
         $response = $view;
     }
     return $response;
 }