php - Checking to see if a conversation already exists Laravel -
hey guys i'm building eloquent query see conversation array of participants exists. reason can't have same conversation same participants created more once.
here's eloquent query:
$convos = conversation::wherehas('participant', function ($query) use ($participantids) { $query->wherein('user_id', $participantids) ->groupby('convo_id') ->havingraw('count(convo_id)='.count($participantids)); })->get();
$participantids equal [1, 2] or [1, 2, 3] example.
how check if conversation exists id's in $participantids? above query return conversation has any of participants in array
so if have conversation john (2) , matt (4) try make conversation me , john query show have conversation john already
Comments
Post a Comment