|
@@ -702,7 +702,7 @@ class ChatService implements ChatServiceInterface
|
|
|
$where[] = ['chat_topics.title', 'like', '%' . $data['title'] . '%'];
|
|
|
}
|
|
|
if (!empty($data['user_id'])) {
|
|
|
- $where[] = ['user_id', '=', $data['user_id']];
|
|
|
+ $where[] = ['chat_topics.user_id', '=', $data['user_id']];
|
|
|
}
|
|
|
if (!empty($data['status'])) {
|
|
|
$where[] = ['chat_topics.status', '=', $data['status']];
|
|
@@ -716,7 +716,11 @@ class ChatService implements ChatServiceInterface
|
|
|
var_dump($where);
|
|
|
$result = ChatTopic::where($where)
|
|
|
->leftJoin('user', 'user.id', '=', 'chat_topics.user_id')
|
|
|
- ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name')
|
|
|
+ ->leftJoin('chat_topics_reply', 'chat_topics.id', '=', 'chat_topics_reply.topic_id')
|
|
|
+ ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name'
|
|
|
+ ,
|
|
|
+ DB::raw('count(chat_topics_reply.id) as num'))
|
|
|
+ ->groupBy('chat_topics.id')
|
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page'] ?? 1);
|
|
|
return Result::success($result);
|
|
|
}
|