interestCircleUser = $interestCircleUser; $this->interestCircle = $interestCircle; } /** * 用户列表 */ public function lists($request) { $perPage = isset($request['per_page']) ? $request['per_page'] : 20; $where = []; if (isset($request['uid'])) { $where[] = ['uid', $request['uid']]; } if (isset($request['user_type'])) { $where[] = ['is_black', $request['user_type']]; } if (isset($request['circle_id'])) { $where[] = ['circle_id', $request['circle_id']]; } $userModel = $this->interestCircleUser; return $userModel ->where($where) ->orderBy('created_at', 'desc') ->paginate($perPage); } /** * 设置该用户为当前圈子黑名单 */ public function setUserBlack($request) { $article = $this->interestCircleUser ->where('uid', $request['uid']) ->where('circle_id', $request['circle_id']) ->first(); if (!$article) { return Response::create([ 'message' => '当前用户不在该圈子', 'status_code' => 500 ]); } if ($article->is_black == 1) { $article->is_black = 0; } else { $article->is_black = 1; } DB::beginTransaction(); try { $article->save(); DB::commit(); return Response::create(); } catch (QueryException $exception) { DB::rollBack(); Log::debug('设置圈子黑名单:' . $request['uid'] . '-' . $request['circle_id'] . $exception->getMessage()); return Response::create([ 'message' => '操作失败,请重试', 'error' => $exception->getMessage(), 'status_code' => 500 ]); } } }