id === (int) $id; }); Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) { return Conversation::where('id', $conversationId) ->whereHas('users', fn ($q) => $q->where('user_id', $user->id) )->exists(); }); Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) {return Conversation::where('id', $conversationId)->whereHas('users', function ($q) use ($user) {$q->where('user_id', $user->id);})->exists();});