public function conocenos() { $galerias = \App\galeria::select('id_tipo_galeria as id')->get(); $datos = array(); foreach ($galerias as $val) { $datos[] = $val->id; } return view('public/conocenos', ['categorias' => \DB::table('tipo_galeria')->select('id_tipo_galeria as id', 'nombre')->where('activo', '=', 1)->whereIn('tipo_galeria.id_tipo_galeria', $datos)->get()]); }
public function destroy(Request $request) { $id = $request->id; $imagenes = \App\elemento::where('tipo_elemento', '=', 1)->where('id_galeria', '=', $id)->get(); $portada = \App\galeria::find($id); $portada = $portada->portada; if (\DB::statement('CALL del_galeria(' . $id . ')')) { foreach ($imagenes as $val) { if (file_exists(getcwd() . $val->url)) { echo getcwd() . $val->url; unlink(getcwd() . $val->url); } } } if (file_exists(getcwd() . $portada)) { unlink(getcwd() . $portada); } $portada = explode("/", $portada); array_pop($portada); $portada = implode("/", $portada); rmdir(getcwd() . $portada); }
public function getPerfilServicio($id) { $valoracion = new valoracion(); $servicio = entidadTuristica::where('rif', $id)->first(); $imagenes = galeria::where('identidad', $id)->get(); $visitas = new visitas(); $visitas = $visitas->createNew($id); //Hacer esto con query con prioridad etc.... $relacionados = entidadTuristica::where(function ($q) use($servicio) { $q->where("idciudad", $servicio->idciudad)->orWhere("idestado", $servicio->idestado); })->where("tipoentidad", $servicio->tipoentidad)->where('rif', "!=", $servicio->rif)->take(3)->get(); if (Session::has('usrEmail')) { $usrValoracion = valoracion::where('identidad', $id)->where('state', 'Aceptado')->where('idusuario', Session::get('usrEmail'))->first(); } else { $usrValoracion = null; } $comentarios = $valoracion->getValoraciones($id); $valoracion = $valoracion->getCalificacion($id); $data = ['servicio' => $servicio, 'imagenes' => $imagenes, 'relacionados' => $relacionados, 'comentarios' => $comentarios, 'valoracion' => $valoracion, 'usrValoracion' => $usrValoracion]; return View::make('web.perfilServicio')->with($data); }
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 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); } }
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; }