I have a basic private messaging system which is capable of having 1 to 1 conversations and group conversations.
Currently I have a "Send Message" widget box across the site where the user can type in the name of the user and send a message to them which begins a "1 to 1" conversation thread.
What I need this widget to do is, when a message is sent, check to see if a conversation between the two users already exists, and if it does, add the new message to the already existing conversation thread. If the conversation does not exist, then start a new thread.
My main issue is, how can I exclude checking group conversation threads where both users are participants.
A snippet of the 2 relevant tables are as follows:
threads Table:
- Title
- Type
thread_participants Table
- thread_id
- user_id
The thread "type" determines if the thread is a "single" (1-1 conversation) or "group" conversation.
My theory is to search through the thread table finding where two users are in the same thread however I am unsure how I can do this using eloquent in my controller.
Hope that is clear. Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire