public function deleteById($id) { $isDeleted = valoracion::where('id', $id)->delete(); return $isDeleted; }
public function deleteComment(Request $request) { $valoracion = new valoracion(); if ($request->ajax()) { if ($request->has('id')) { $isDeleted = $valoracion->deleteById($request->id); } else { $isDeleted = false; } if ($isDeleted) { $response = Response::json(['success' => true, 'message' => 'Operacion realizada con éxito.'], 200); } else { $response = Response::json(['success' => false, 'message' => 'Error al realizar la operación.'], 400); } } else { $response = Response::json(['success' => false, 'message' => 'Error, id no suministrado.'], 400); } return $response; }
public function postAceptComent(Request $request) { $val = valoracion::where('id', $request->id)->update(['state' => 'Aceptado']); if ($val) { return $response = Response::json(['success' => true], 200); } else { return $response = Response::json(['success' => false, 'message' => 'Error al modificar la valoración'], 400); } }
public function getListaComentarios(Request $request) { $toMatch = ['identidad' => Session::get("idEnt")]; $dateNow = new Carbon('today'); $dateLastWeek = new Carbon('last week'); $dateLastMonth = new Carbon('last Month'); //Haciendo query segun fecha... if ($request->has('date')) { if ($request->date == 'semana') { $valoraciones = valoracion::where($toMatch)->where("created_at", ">=", $dateLastWeek->toDateTimeString())->where("created_at", "<=", $dateNow->toDateTimeString())->orderBy('created_at', 'DESC')->paginate(4); } elseif ($request->date == 'mes') { $valoraciones = valoracion::where($toMatch)->where("created_at", ">=", $dateLastMonth->toDateTimeString())->where("created_at", "<=", $dateNow->toDateTimeString())->orderBy('created_at', 'DESC')->paginate(4); } else { $valoraciones = valoracion::where($toMatch)->orderBy('created_at', 'DESC')->paginate(4); } } else { $valoraciones = valoracion::where($toMatch)->orderBy('created_at', 'DESC')->paginate(4); } $view = View::make('adminHotel.lista-comentarios')->with(['valoraciones' => $valoraciones]); $sections = $view->renderSections(); $response = Response::json(['success' => true, 'data' => $sections['lista-comentarios']], 200); return $response; }