Skip to content

Commit

Permalink
added whereNotReadBywhereNotDeliveredTo whereNotDeletedBy query…
Browse files Browse the repository at this point in the history
… methods
  • Loading branch information
myckhel committed Sep 25, 2021
1 parent baf8004 commit a5ca043
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ function scopeWhereDoesntHaveChatEvents($q, $type = null, ChatEventMaker|int $us
}
}

function scopeWhereNotReadBy($q, ChatEventMaker|int $user) {
return $q->whereDoesntHaveChatEvents('read', $user);
}

function scopeWhereNotDeliveredTo($q, ChatEventMaker|int $user) {
return $q->whereDoesntHaveChatEvents('deliver', $user);
}

function scopeWhereNotDeletedBy($q, ChatEventMaker|int $user) {
return $q->whereDoesntHaveChatEvents('delete', $user);
}

function scopeWhereRelatedToUser($q, ChatEventMaker|int $user) {
$q->whereHas('conversation', fn ($q) =>
$q->whereHas('participants', fn ($q) => $q->whereUserId($user->id ?? $user))
Expand Down

0 comments on commit a5ca043

Please sign in to comment.