user(); $list = $user->scores()->filter($request->all())->sort()->paginate($request->input('per_page')); return $this->response()->success(UserScoreResource::collection($list)); } public function show($id) { $user = auth('api')->user(); $info = $user->scores()->with(['type', 'checkUser'])->findOrFail($id); return $this->response()->success(UserScoreResource::make($info)); } public function store(Request $request) { $user = auth('api')->user(); $params = $request->all(); $params['user_id'] = $user->id; $service = UserScoreService::make(); $result = $service->store($params); if ($result) { return $this->response()->success(); } return $this->response()->fail($service->getError()); } public function update(Request $request) { $user = auth('api')->user(); $info = $user->scores()->findOrFail($id); if ($info->check_status == CheckStatus::Success) { return $this->response()->fail('审核已通过, 无法修改'); } $info->update($request->only(['title', 'content', 'images', 'file'])); return $this->response()->success(); } public function destroy($id) { $user = auth('api')->user(); $info = $user->scores()->findOrFail($id); if ($info->check_status == CheckStatus::Success) { return $this->response()->fail('审核已通过, 无法删除'); } UserScoreService::make()->delete($id); return $this->response()->success(); } }