Beispiel #1
0
 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);
 }
Beispiel #2
0
 public function deleteFile(Request $request)
 {
     if ($request->has("fotos")) {
         foreach ($request->fotos as $foto) {
             if ($request->has("habitacion")) {
                 $fotoDelete = galeriaHabitacion::where("id", $foto)->first();
             } else {
                 $fotoDelete = galeria::where("id", $foto)->first();
             }
             $rutaFoto = public_path() . "/imagesUploaded" . "/" . $fotoDelete->nombre;
             File::delete($rutaFoto);
             $fotoDelete->delete();
         }
         if ($request->deleteImagePerfil == true) {
             if ($request->has("habitacion")) {
                 $habit = habitacion::where('id', $request->habitacion)->update(['imagen' => null]);
             } else {
                 $entidadTuristica = entidadTuristica::where('rif', Session::get("idEnt"))->update(['imagen' => null]);
             }
         }
         //dd($count);
         $response = Response::json(["message" => "Imagenes eliminadas con exito."], 200);
         return $response;
     } else {
         return Response::json(["message" => "Error al eliminar las imagenes"], 400);
     }
 }