/** * Get annotations by document ID and annotation ID. * * @param integer $docId * @param string $annotationId optional, if not provided get all * * @throws Exception */ public function getIndex($docId, $annotationId = null) { try { $userId = null; if (Auth::check()) { $userId = Auth::user()->id; } $results = Annotation::loadAnnotationsForAnnotator($docId, $annotationId, $userId); } catch (Exception $e) { throw $e; App::abort(500, $e->getMessage()); } if (isset($annotationId)) { return Response::json($results[0]); } return Response::json($results); }