Skip to content

Commit

Permalink
feat(core): 未读消息列表返回三条语言消息( #337 )
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Aug 14, 2018
1 parent 96e5dd1 commit aa020ec
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Http/Controllers/APIs/V2/UserUnreadCountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Illuminate\Support\Collection;
use Zhiyi\Plus\Models\Like as LikeModel;
use Zhiyi\Plus\Models\Comment as CommentModel;
use Zhiyi\Plus\Models\AtMessage as AtMessageModel;
use Zhiyi\Plus\Support\PinnedsNotificationEventer;
use Zhiyi\Plus\Models\Conversation as ConversationModel;

Expand Down Expand Up @@ -100,13 +101,24 @@ public function index(Request $request, CommentModel $commentModel, LikeModel $l
->whereNull('read_at')
->count();

// at 最近三个用户
$atMeUsers = (new AtMessageModel)->query()
->where('user_id', $user->id)
->limit(3)
->orderBy('id', 'desc')
->select('user_id')
->get()
->pluck('user_id')
->all();

$counts->system = $systemUnreadCount ?? 0;
$result = array_filter([
'counts' => $counts,
'comments' => $comments,
'likes' => $likes,
'pinneds' => $pinneds,
'system' => $lastSystem,
'atme' => $atMeUsers,
], function ($item) {
if (is_null($item)) {
return false;
Expand Down

0 comments on commit aa020ec

Please sign in to comment.