feat: add Reverb realtime messaging
This commit is contained in:
@@ -23,14 +23,18 @@ class Conversation extends Model
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'type',
|
||||
'title',
|
||||
'created_by',
|
||||
'last_message_id',
|
||||
'last_message_at',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'last_message_at' => 'datetime',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
// ── Relationships ────────────────────────────────────────────────────────
|
||||
@@ -81,6 +85,7 @@ class Conversation extends Model
|
||||
{
|
||||
return self::query()
|
||||
->where('type', 'direct')
|
||||
->where('is_active', true)
|
||||
->whereHas('allParticipants', fn ($q) => $q->where('user_id', $userA)->whereNull('left_at'))
|
||||
->whereHas('allParticipants', fn ($q) => $q->where('user_id', $userB)->whereNull('left_at'))
|
||||
->whereRaw(
|
||||
@@ -108,6 +113,11 @@ class Conversation extends Model
|
||||
->whereNull('deleted_at')
|
||||
->where('sender_id', '!=', $userId);
|
||||
|
||||
if ($participant->last_read_message_id) {
|
||||
$query->where('id', '>', $participant->last_read_message_id);
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
if ($participant->last_read_at) {
|
||||
$query->where('created_at', '>', $participant->last_read_at);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user