DB::table('group_lists')
->join('conversationsV2', 'group_lists.conversationsV2_id', '=', 'conversationsV2.id')
->join('messagesV2', 'group_lists.conversationsV2_id', '=', 'messagesV2.conversationsV2_id')
->whereIn('group_lists.conversationsV2_id', function ($query) use ($userID) {
$query->select('conversationsV2_id')->from('group_lists')
->where('user_id', $userID)->get();
})
->select('group_lists.user_id', 'conversationsV2.id', 'conversationsV2.type',
DB::raw('max(messagesV2.id) as mid')
, 'group_lists.conversationsV2_id')
->where('group_lists.user_id', '!=', $userID)
->groupBy('messagesV2.conversationsV2_id')
->orderBy('messagesV2.id', 'DESC')
->get();
MessageV2
the Line ->orderBy('messagesV2.id', 'DESC')
is not working due to ->groupBy('messagesV2.conversationsV2_id')
so there any way i can groupby and orderby at the same time
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire