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

One-to-one facebook style messaging. #29

Closed
naneri opened this issue Apr 13, 2015 · 5 comments
Closed

One-to-one facebook style messaging. #29

naneri opened this issue Apr 13, 2015 · 5 comments

Comments

@naneri
Copy link

naneri commented Apr 13, 2015

How can this be performed? I have went through the methods, but still had to implement my own (i needed to users have only single thread between each other).

@ryross
Copy link

ryross commented Apr 13, 2015

You can just create a Thread with one participant instead of many. See:

https://github.com/cmgmyr/laravel-messenger/blob/master/src/Cmgmyr/Messenger/examples/MessagesController.php#L91

@cmgmyr
Copy link
Owner

cmgmyr commented Apr 13, 2015

That is correct just add the recipient's user id here. You'll have to use this in order to only show threads that the current user is a part of.

You'll also have to implement some sort of check in the show() method in order to make sure the user is really a participant of the thread.

@dorinniscu
Copy link

dorinniscu commented Jun 8, 2016

How do I get the conversation in case of a chat? I have a list of users, I select one and start or continue a conversation so I need to create a thread if not exists.

I suppose I need to get the thread knowing the participants (me and the other person) but we can participate to other threads too so I need to match that specific thread.

Is there an easier way to do that or I have to do other check to get the thread with two persons that are not participating to other threads? something like: "find or create between".

@Gummibeer
Copy link

@dorin-niscu here you go:
https://github.com/cmgmyr/laravel-messenger/blob/master/src/Cmgmyr/Messenger/Models/Thread.php#L173

With the Thread::between([user_ids])->first() you should get the thread, if exists, with the two participants. If not you can simply create a new thread.

@dorinniscu
Copy link

@Gummibeer Thanks. I should have studied the model :)

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

5 participants