Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two user conversations #261

Open
guptanand opened this issue Sep 7, 2020 · 2 comments
Open

Two user conversations #261

guptanand opened this issue Sep 7, 2020 · 2 comments

Comments

@guptanand
Copy link

Hi sir

I have tried to get the conversations message with two users(sender & receiver) but it is return null ,please see my function and tell

public function getConversationWithTwoUsers(Request $request, $withUserId)
{
$user = Auth::user();
$conversation = Chat::conversations()->between($user, User::find($withUserId));
dd($conversation);
}

return null

Thank you

@jim-nnamdi
Copy link

You will need to actually add a second user and pass the Request object to retrieve it, that's what you are missing
in your $conversation variable, try to do User::find($request->withUserId)); and then through your form pass a user id parameter, below is the refactored code.

public function getConversationWithTwoUsers(Request $request, $withUserId)
{
$user = Auth::user();
$conversation = Chat::conversations()->between($user, User::find($request->withUserId));
dd($conversation);
}

@dhi2
Copy link

dhi2 commented Mar 23, 2021

This only gets conversations that are direct, make sure direct_message is 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants