Skip to content

Commit 8c7bf06

Browse files
committed
fix read
1 parent 8626ad8 commit 8c7bf06

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Concerns/ParticipateToConversations.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function denormalizedConversationsUnread(): BelongsToMany
101101
{
102102
return $this
103103
->conversations()
104+
->where('conversations.latest_message_id', '!=', null)
104105
->where(function ($query) {
105106
return $query
106107
->where('conversation_user.last_read_message_id', '=', null)
@@ -118,7 +119,11 @@ public function denormalizedConversationsRead(): BelongsToMany
118119
{
119120
return $this
120121
->conversations()
121-
->wherePivot('last_read_message_id', '>=', DB::raw('conversations.latest_message_id'));
122+
->where(function ($query) {
123+
$query
124+
->where('conversations.latest_message_id', '=', null)
125+
->orWhere('conversation_user.last_read_message_id', '>=', DB::raw('conversations.latest_message_id'));
126+
});
122127
}
123128

124129
/**

0 commit comments

Comments
 (0)