Enhance chat functionality: add support for vendor-specific chat channels, implement methods for managing conversations with admin and store owners, and improve conversation payload structure. Update middleware and policies for better access control, and refine chat UI to indicate view-only status for store owner replies.
This commit is contained in:
1 parent
c55694ec8c
commit
5c17c35741
23 files changed
+729
-59
No files matched your search
@@ -46,10 +46,22 @@ class Channel extends Model implements HasMedia, Sortable
|
||||
'sort_order',
|
||||
'is_default',
|
||||
'is_visible',
|
||||
'chatting',
|
||||
'channelables_type',
|
||||
'channelables_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'is_default' => 'boolean',
|
||||
'is_visible' => 'boolean',
|
||||
'chatting' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Sortable attributes
|
||||
*
|
||||
@@ -158,6 +170,26 @@ public function user(): BelongsTo
|
||||
return $this->belongsTo(User::class, 'channelables_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores that visitors may start a chat with.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder<static> $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder<static>
|
||||
*/
|
||||
public function scopeChatTargets($query, ?User $viewer = null)
|
||||
{
|
||||
$supportId = (int) config('chat.support_user_id');
|
||||
|
||||
return $query
|
||||
->where('is_visible', true)
|
||||
->where('chatting', true)
|
||||
->where('channelables_type', User::class)
|
||||
->whereNotNull('channelables_id')
|
||||
->whereHas('user')
|
||||
->when($viewer, fn ($query) => $query->where('channelables_id', '!=', $viewer->id))
|
||||
->when($supportId > 0, fn ($query) => $query->where('channelables_id', '!=', $supportId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Default tmpost inventory
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user