Beispiel #1
0
 public function getPerfilHotel($id)
 {
     $ent = new entidadTuristica();
     $valoracion = new valoracion();
     $servs = new servicios();
     $camas = new camas();
     $hab = new habitacion();
     $hotel = entidadTuristica::where('rif', $id)->first();
     $disponibilidad = new disponibilidad();
     $imagenes = galeria::where('identidad', $id)->get();
     $servicios = servicios::where('identidad', $id)->first();
     $habitaciones = habitacion::where('identidad', $id)->get();
     $camas = $camas->camasPorHabitacion($habitaciones);
     $habitaciones = $hab->serviciosOrdenados($habitaciones);
     $servicios = (array) $hotel->servicios['attributes'];
     $array_keys = array_keys($servicios);
     unset($array_keys[12]);
     $nombreFotos = $servs->nombreFotos();
     $nombres = $servs->nombres();
     $visitas = new visitas();
     $visitas = $visitas->createNew($id);
     //$dt->daysInMonth
     $desde = Carbon::now();
     $desdeInicio = Carbon::create($desde->year, $desde->month, 1);
     $desdeFin = Carbon::create($desde->year, $desde->month, $desde->daysInMonth);
     $desdeInicio = $desdeInicio->toDateString();
     $desdeFin = $desdeFin->toDateString();
     $dias = 0;
     // -- Busqueda de las habitaciones que estan disponibles en esa fecha para ese hotel --
     if (Session::has('fecha')) {
         $fecha = explode(" - ", Session::get('fecha'));
         $f = new Carbon($fecha[0]);
         $f2 = new Carbon($fecha[1]);
         $dias = $f->diffInDays($f2);
         $query = " SELECT idperfilhabitacion FROM habitacionesperfil WHERE id NOT IN ( SELECT disponibilidad.idhabitacion from disponibilidad WHERE (estado = 'Habilitado')\n            AND ((disponibilidad.fecha_inicio BETWEEN '" . $fecha[0] . "' AND '" . $fecha[1] . "')\n            OR (disponibilidad.fecha_fin BETWEEN '" . $fecha[0] . "' AND '" . $fecha[1] . "')\n            OR ( ('" . $fecha[0] . "' >= disponibilidad.fecha_inicio) AND ('" . $fecha[1] . "' <= disponibilidad.fecha_fin) ) ) ) ";
         $search = DB::select(DB::raw($query));
         $arraySearch = [];
         foreach ($search as $s) {
             array_push($arraySearch, $s->idperfilhabitacion);
         }
         foreach ($habitaciones as $h) {
             $h['disponible'] = in_array($h->id, $arraySearch);
         }
     }
     if (Session::has('usrEmail')) {
         $usrValoracion = $valoracion->getValoracion(Session::get('usrEmail'));
         if (count($usrValoracion) == 0) {
             $usrValoracion = null;
         } else {
             $usrValoracion = $usrValoracion[0];
         }
     } else {
         $usrValoracion = null;
     }
     //-- Busqueda de hoteles relacionados --
     //Hacer esto con query con prioridad etc....
     $relacionados = entidadTuristica::where(function ($q) use($hotel) {
         $q->where("idciudad", $hotel->idciudad)->orWhere("idestado", $hotel->idestado);
     })->where("tipoentidad", $hotel->tipoentidad)->where('rif', "!=", $hotel->rif)->take(3)->get();
     $comentarios = $valoracion->getValoraciones($id);
     $valoracion = $valoracion->getCalificacion($id);
     //servicios de habitacion pagos....
     $servsHabs = [];
     foreach ($habitaciones as $h) {
         foreach ($h->servicios2 as $s) {
             if (!in_array($s, $servsHabs)) {
                 array_push($servsHabs, $s);
             }
         }
     }
     $data = ['hotel' => $hotel, 'imagenes' => $imagenes, 'servicios' => $servicios, 'habitaciones' => $habitaciones, 'array_keys' => $array_keys, 'nombreFotos' => $nombreFotos, 'nombres' => $nombres, 'relacionados' => $relacionados, 'comentarios' => $comentarios, 'valoracion' => $valoracion, 'usrValoracion' => $usrValoracion, 'dias' => $dias, 'desdeInicio' => $desdeInicio, 'desdeFin' => $desdeFin, 'servsHab' => $servsHabs];
     return View::make('web.perfilHotel')->with($data);
 }
Beispiel #2
0
 public function getServices(Request $request)
 {
     $servs = new servicios();
     $hotel = entidadTuristica::where('rif', Session::get("idEnt"))->first();
     $servicios = (array) $hotel->servicios['attributes'];
     $array_keys = array_keys($servicios);
     unset($array_keys[12]);
     $nombreFotos = $servs->nombreFotos();
     $nombres = $servs->nombres();
     $respuesta = ['servicios' => $servicios, 'array_keys' => $array_keys, 'nombres' => $nombres, 'nombreFotos' => $nombreFotos];
     $view = View::make('adminHotel.serviciosHotel')->with($respuesta);
     if ($request->ajax()) {
         $sections = $view->renderSections();
         $response = Response::json(['success' => true, 'data' => $sections['serviciosHotel']], 200);
     } else {
         $response = $view;
     }
     return $response;
 }
 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;
 }
 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;
 }