Implement chat support functionality: update .env.example for Reverb integration, enhance ChatController with support conversation methods, and modify Conversation model for improved chat handling. Add middleware for chat operator checks and update broadcasting configuration for Reverb.
This commit is contained in:
@@ -30,9 +30,23 @@ class MessageSent implements ShouldBroadcast
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
$channels = [
|
||||
new PrivateChannel('chat.'.$this->message->conversation_id),
|
||||
];
|
||||
|
||||
$supportId = (int) config('chat.support_user_id');
|
||||
|
||||
if ($supportId > 0) {
|
||||
$isSupportConversation = $this->message->conversation()
|
||||
->whereHas('users', fn ($query) => $query->where('users.id', $supportId))
|
||||
->exists();
|
||||
|
||||
if ($isSupportConversation) {
|
||||
$channels[] = new PrivateChannel('chat.support');
|
||||
}
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public function broadcastAs(): string
|
||||
|
||||
Reference in New Issue
Block a user