update pusher

This commit is contained in:
2024-05-14 13:22:16 +07:00
parent cd9fff3265
commit c07241397f
2 changed files with 6 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
namespace Modules\Linksehat\Http\Controllers\Api;
use App\Models\Channel;
use App\Events\ChatMessageSent;
use App\Models\UserChannel;
use App\Models\Message;
use App\Models\File;
@@ -72,8 +73,8 @@ class ChatController extends Controller
if (!$channel) {
$dataChannel = Channel::where('doctor_id',$request->user_id)->get()->toArray();
$data = [];
if ($dataChannel){
$data = [];
foreach($dataChannel as $d){
$user = User::with('detail')->where('nID', $d['member_id'])->first();
$lastMessage = Message::where('channel_id', $d['id'])
@@ -150,6 +151,8 @@ class ChatController extends Controller
$person = User::where('nID', $channel->member_id)->first();
$name = $person->sFirstName . ' ' . $person->sLastName;
}
ChatMessageSent::dispatch($message);
return response()->json([
'message' => 'Message sent successfully',

View File

@@ -24,6 +24,7 @@ class ChatMessageSent implements ShouldBroadcast
public function __construct($message)
{
$this->message = $message;
$this->dontBroadcastToCurrentUser();
}
/**
@@ -33,7 +34,7 @@ class ChatMessageSent implements ShouldBroadcast
*/
public function broadcastOn()
{
return new PrivateChannel('chat');
return new PrivateChannel('chat'. $this->message->channel_id);
}
}