1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-24 16:53:17 +00:00

Update DirectMessageController

This commit is contained in:
Daniel Supernault 2019-01-31 13:26:16 -07:00
parent d714381fd5
commit d48f15a036
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -20,11 +20,12 @@ class DirectMessageController extends Controller
public function inbox(Request $request) public function inbox(Request $request)
{ {
$profile = Auth::user()->profile; $profile = Auth::user()->profile;
$inbox = DirectMessage::whereToId($profile->id) $inbox = DirectMessage::selectRaw('*, max(created_at) as createdAt')
->whereToId($profile->id)
->with(['author','status']) ->with(['author','status'])
->orderBy('created_at', 'desc') ->orderBy('createdAt', 'desc')
->groupBy('from_id') ->groupBy('from_id')
->paginate(10); ->paginate(12);
return view('account.messages', compact('inbox')); return view('account.messages', compact('inbox'));
} }
@ -40,10 +41,12 @@ class DirectMessageController extends Controller
$msg = DirectMessage::whereToId($profile->id) $msg = DirectMessage::whereToId($profile->id)
->findOrFail($mid); ->findOrFail($mid);
$thread = DirectMessage::whereToId($profile->id) $thread = DirectMessage::whereIn('to_id', [$profile->id, $msg->from_id])
->orWhere([['from_id', $profile->id],['to_id', $msg->from_id]]) ->whereIn('from_id', [$profile->id,$msg->from_id])
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->paginate(10); ->paginate(30);
$thread = $thread->reverse();
return view('account.message', compact('msg', 'profile', 'thread')); return view('account.message', compact('msg', 'profile', 'thread'));
} }