|
@@ -48,20 +48,18 @@ class ChatService implements ChatServiceInterface
|
|
|
$keyword = $data['keyword'];
|
|
|
$userId = $data['user_id'];
|
|
|
|
|
|
- $result = User::where('user_name', 'like', '%' . $data['keyword'] . '%')
|
|
|
- ->orWhere('user.nickname', 'like', '%' . $data['keyword'] . '%')
|
|
|
- ->orWhere('user.mobile', 'like', '%' . $data['keyword'] . '%')
|
|
|
- ->where('user.id', '<>', $userId)
|
|
|
- ->where('user.type_id', '<>', 20000)
|
|
|
-
|
|
|
- ->select(
|
|
|
- 'user.*',
|
|
|
- 'chat_friends.friend_id'
|
|
|
- )
|
|
|
- ->leftJoin('chat_friends', function ($join) use ($userId) {
|
|
|
- $join->on('user.id', '=', 'chat_friends.friend_id')
|
|
|
- ->where('chat_friends.user_id', '=', $userId);
|
|
|
+ $result = User::leftJoin('chat_friends', function ($join) use ($userId) {
|
|
|
+ $join->on('user.id', '=', 'chat_friends.friend_id')
|
|
|
+ ->where('chat_friends.user_id', '=', $userId);
|
|
|
+ })
|
|
|
+ ->where(function ($query) use ($data) {
|
|
|
+ $query->where('user.user_name', 'like', '%' . $data['keyword'] . '%')
|
|
|
+ ->orWhere('user.nickname', 'like', '%' . $data['keyword'] . '%')
|
|
|
+ ->orWhere('user.mobile', 'like', '%' . $data['keyword'] . '%');
|
|
|
})
|
|
|
+ ->where('user.id', '<>', $userId)
|
|
|
+ ->where('user.type_id', '<>', '20000')
|
|
|
+ ->select('user.*', 'chat_friends.friend_id')
|
|
|
->get();
|
|
|
|
|
|
return Result::success($result);
|