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($id, Request $request) { $user = auth('api')->user(); $info = $user->scores()->findOrFail($id); if ($info->check_status == CheckStatus::Success) { return $this->response()->fail('审核已通过, 无法修改'); } $params = $request->only(['title', 'content', 'images', 'file']); if ($info->check_status == CheckStatus::Fail) { $params['created_at'] = now(); $params['check_status'] = CheckStatus::None; $params['check_at'] = null; $params['check_user_id'] = null; } $info->update($params); 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(); } }