/** * @param $id * @param Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function update($id, Request $request) { $annotation = Annotation::find($id); if ($annotation) { $data = json_decode($request->getContent(), true); $annotation->ranges = $data['ranges']; $annotation->quote = $data['quote']; $annotation->text = $data['text']; $annotation->page_id = $data['page']; try { $annotation->save(); return response()->json(['status' => 'success']); } catch (\Exception $e) { return response()->json(['status' => 'error', 'message' => $e->getMessage()], 400); } } return response()->json(['status' => 'error', 'message' => 'Could not find the annotation.'], 400); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $annotation = Annotation::find($id); $annotation->delete(); return redirect('annotations'); }
public function postFlags($doc, $annotation = null) { if ($annotation === null) { App::abort(404, 'No note id passed'); } $annotation = Annotation::find($annotation); $annotation->saveUserAction(Auth::user()->id, Annotation::ACTION_FLAG); return Response::json($annotation->toAnnotatorArray()); }