[英]Retrieving the last user message from chat - inbox
我正在建立我网站的聊天部分,这是我为检索收件箱和对话的最后一条消息而提出的查询。
$chat_inbox = Message::where('author_id', $this->user->id)
->orWhere('recipient_id', $this->user->id)
->groupBy('unique_chat_id')
->latest();
问题是我需要找到其他用户发送的最后一条消息,而不是发送消息的那个。 然后我可以在收件箱中将此消息显示为未读,但我还需要检索当前用户开始的对话,即使其他用户仍未响应。
无论是谁发送的,此当前查询都会为我提供最后一条消息。 任何帮助表示赞赏。
您必须更改where
的语句。
$chat_inbox = Message::where('recipient_id', $this->user->id)
->where('chat_id', some_id')
->groupBy('unique_chat_id')
->last();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.