|
@@ -43,8 +43,41 @@ class CircleController extends Controller
|
|
|
$this->circleMessageRepository = $circleMessageRepository;
|
|
|
}
|
|
|
|
|
|
- public function valid(Request $request){
|
|
|
+ /**
|
|
|
+ * 圈子检测
|
|
|
+ * @param Request $request
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function valid(Request $request)
|
|
|
+ {
|
|
|
+ $userInfo = $this->getUserInfo();
|
|
|
+ if ($userInfo) {
|
|
|
+ $uid = $userInfo['uid'];
|
|
|
+ } else {
|
|
|
+ $uid = 0;
|
|
|
+ }
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'id' => 'required|exists:interest_circles'
|
|
|
+ ]);
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->jsonError($validator->errors()->first());
|
|
|
+ }
|
|
|
+ $request = $request->all();
|
|
|
+ $circleInfo = $this->circleRepository->detail($request);
|
|
|
+ if ($circleInfo && $circleInfo->is_open == 0) {
|
|
|
+ return $this->jsonError('当前圈子已关闭');
|
|
|
+ }
|
|
|
+ if ($uid) {
|
|
|
+ $row = $this->circleMemberRepository
|
|
|
+ ->where('circle_id', $request['id'])
|
|
|
+ ->where('uid', $uid)
|
|
|
+ ->where('is_black', 1)->exists();
|
|
|
+ if ($row) {
|
|
|
+ return $this->jsonError('您无法进入该聊天室');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ return $this->jsonSuccess();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -202,7 +235,8 @@ class CircleController extends Controller
|
|
|
return jsonSuccess($data);
|
|
|
}
|
|
|
|
|
|
- public function messageList(Request $request){
|
|
|
+ public function messageList(Request $request)
|
|
|
+ {
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'id' => 'required|exists:interest_circles'
|
|
|
]);
|