WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c192dd0

Browse files
committed
add check for last_read is null, fixes #10
1 parent c0afcc7 commit c192dd0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Cmgmyr/Messenger/Models/Thread.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ public function scopeForUserWithNewMessages($query, $userId)
115115
{
116116
return $query->join('participants', 'threads.id', '=', 'participants.thread_id')
117117
->where('participants.user_id', $userId)
118-
->where('participants.deleted_at', null)
119-
->where('threads.updated_at', '>', $this->getConnection()->raw('participants.last_read'))
118+
->whereNull('participants.deleted_at')
119+
->where(function ($query) {
120+
$query->where('threads.updated_at', '>', $this->getConnection()->raw('participants.last_read'))
121+
->orWhereNull('participants.last_read');
122+
})
120123
->select('threads.*')
121124
->latest('updated_at')
122125
->get();

0 commit comments

Comments
 (0)