function peticionesByCategoria(Request $request, Response $response) { $response = $response->withHeader('Content-type', 'application/json'); $categoria = $request->getAttribute('id'); $data = Peticion::where("idCategoria", "=", $categoria)->get(); formatearFecha($data); if (count($data) == 0) { $response = $response->withStatus(404); } $response->getBody()->write($data); return $response; }