Closed naneri closed 9 years ago
You can just create a Thread with one participant instead of many. See:
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".
@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.
@Gummibeer Thanks. I should have studied the model :)
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).