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); }
public function updateServicios(Request $request) { $hotel = entidadTuristica::where('rif', Session::get("idEnt"))->first(); $servicios = (array) $hotel->servicios['attributes']; $array_keys = array_keys($servicios); unset($array_keys[12]); //dd($request->all()); //Seteando todos en null... foreach ($array_keys as $key) { $servicesForUpdate[$key] = 0; } $servicesActive = $request->servicios; $servicesActive2 = $request->servicios2; if (!$request->has('noService')) { foreach ($servicesActive as $service) { $servicesForUpdate[$service] = 1; } if ($servicesActive2 != null) { foreach ($servicesActive2 as $service) { $servicesForUpdate[$service] = 2; } } } //dd($servicesForUpdate); $servicesForUpdate['identidad'] = $hotel->rif; $updateSuccess = servicios::where('identidad', $hotel->rif)->update($servicesForUpdate); if ($updateSuccess) { return Response::json(['message' => "¡Datos guardados con exito!"], 200); } else { return Response::json(['message' => "¡Error al hacer update!"], 400); } }