Skip to content

Commit c0c9184

Browse files
authored
fixes Thread->scopeBetweenOnly to use participantTable (table name was hardcoded before) (#391)
1 parent 14b72e1 commit c0c9184

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Models/Thread.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,13 @@ public function scopeForUserWithNewMessages(Builder $query, $userId)
222222
*/
223223
public function scopeBetweenOnly(Builder $query, array $participants)
224224
{
225-
return $query->whereHas('participants', function (Builder $builder) use ($participants) {
225+
$participantTable = Models::table('participants');
226+
227+
return $query->whereHas('participants', function (Builder $builder) use ($participants, $participantTable) {
226228
return $builder->whereIn('user_id', $participants)
227-
->groupBy('participants.thread_id')
228-
->select('participants.thread_id')
229-
->havingRaw('COUNT(participants.thread_id)=?', [count($participants)]);
229+
->groupBy($participantTable.'.thread_id')
230+
->select($participantTable.'.thread_id')
231+
->havingRaw('COUNT('.$participantTable.'.thread_id)=?', [count($participants)]);
230232
});
231233
}
232234

0 commit comments

Comments
 (0)