public function destroy(Request $request) { try { if ($request->input('id') == "") { throw new ListItemException('destroy : list id can\'t be null'); } $userid = Auth::user()->id; $listid = $request->input('id'); $listItem = ListItem::where('id', $listid)->where('belong', $userid)->first(); $listItem->isuse = 0; $listItem->save(); return Response()->json(['errno' => 0, 'type' => 'succ', 'msg' => (object) array()]); } catch (ListItemException $e) { return Response()->json(['errno' => 2, 'type' => 'fail', 'msg' => $e->getMessage()]); } catch (Exception $e) { Log::error($e); return Response()->json(['errno' => 1, 'type' => 'fail', 'msg' => 'Whoops, looks like something went wrong']); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function show($id) { $user = Auth::user()->id; $lists = ListItem::where('user_id', '=', $user)->where('category_id', '=', $id)->get(); return Response::json($lists, 200); }