Skip to content

Commit 8626ad8

Browse files
committed
fix
1 parent 8154588 commit 8626ad8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Concerns/ParticipateToConversations.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function getModelMessage(): string
6161
}
6262

6363
/**
64-
* @return BelongsToMany<TConversation, $this>
64+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
6565
*/
6666
public function conversations(): BelongsToMany
6767
{
@@ -75,7 +75,7 @@ public function conversations(): BelongsToMany
7575
/**
7676
* Return unread conversations using the `message_reads` table
7777
*
78-
* @return BelongsToMany<TConversation, $this>
78+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
7979
*/
8080
public function conversationsUnread(): BelongsToMany
8181
{
@@ -85,7 +85,7 @@ public function conversationsUnread(): BelongsToMany
8585
/**
8686
* Return read conversations using the `message_reads` table
8787
*
88-
* @return BelongsToMany<TConversation, $this>
88+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
8989
*/
9090
public function conversationsRead(): BelongsToMany
9191
{
@@ -95,24 +95,24 @@ public function conversationsRead(): BelongsToMany
9595
/**
9696
* Return unread conversations using the pivot column `conversation_user.last_read_message_id`
9797
*
98-
* @return BelongsToMany<TConversation, $this>
98+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
9999
*/
100100
public function denormalizedConversationsUnread(): BelongsToMany
101101
{
102102
return $this
103103
->conversations()
104104
->where(function ($query) {
105105
return $query
106-
->wherePivot('last_read_message_id', '=', null)
107-
->orWherePivot('last_read_message_id', '<', DB::raw('conversations.latest_message_id'));
106+
->where('conversation_user.last_read_message_id', '=', null)
107+
->orWhere('conversation_user.last_read_message_id', '<', DB::raw('conversations.latest_message_id'));
108108
});
109109

110110
}
111111

112112
/**
113113
* Return read conversations using the pivot column `conversation_user.last_read_message_id`
114114
*
115-
* @return BelongsToMany<TConversation, $this>
115+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
116116
*/
117117
public function denormalizedConversationsRead(): BelongsToMany
118118
{
@@ -122,31 +122,31 @@ public function denormalizedConversationsRead(): BelongsToMany
122122
}
123123

124124
/**
125-
* @return BelongsToMany<TConversation, $this>
125+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
126126
*/
127127
public function conversationsNotMuted(): BelongsToMany
128128
{
129129
return $this->conversations()->wherePivot('muted_at', null);
130130
}
131131

132132
/**
133-
* @return BelongsToMany<TConversation, $this>
133+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
134134
*/
135135
public function conversationsMuted(): BelongsToMany
136136
{
137137
return $this->conversations()->wherePivot('muted_at', '!=', null);
138138
}
139139

140140
/**
141-
* @return BelongsToMany<TConversation, $this>
141+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
142142
*/
143143
public function conversationsNotArchived(): BelongsToMany
144144
{
145145
return $this->conversations()->wherePivot('archived_at', null);
146146
}
147147

148148
/**
149-
* @return BelongsToMany<TConversation, $this>
149+
* @return BelongsToMany<TConversation, $this, TConversationUser, 'conversationUser'>
150150
*/
151151
public function conversationsArchived(): BelongsToMany
152152
{

src/ConversationUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function isMessageRead(Message|int $message): bool
7171
{
7272
$messageId = $message instanceof Message ? $message->id : $message;
7373

74-
return $this->last_read_message_id === null || $this->last_read_message_id >= $messageId;
74+
return $this->last_read_message_id && $this->last_read_message_id >= $messageId;
7575
}
7676

7777
public function markAsDenormalizedRead(Message|int $message): static

0 commit comments

Comments
 (0)