-
Notifications
You must be signed in to change notification settings - Fork 308
Open
Description
I'm trying to retrieve a list of all the Models (participants) that a certain Model ever had a conversation with.
My chat screen has 3 columns:
- list of contacts (grouped, so each contact is displayed only once and sorted by latest message first)
- list of conversations with the selected contact
- messages inside the selected conversation
My question is regarding the first column. Is this possible?
I tried it with this query to get all participants for User with id 1, which works, but doesn't group the participants:
Musonza\Chat\Models\Conversation::query()
->whereHas('participants', function($query) {
$query->whereHasMorph(
'messageable',
[User::class],
function ($query) {
$query->where('id', 1);
})
->groupBy(['messageable_type', 'messageable_id']);
})
->get()
Metadata
Metadata
Assignees
Labels
No labels