I hope anybody can help me with this.
I have the next eloquent query:
$chats = Solicitud::with(['reservation', 'detail.subDetails', 'conversation'=>function($q){
$q->orderBy('created_at', 'DESC')->groupBy('solicitud')->first();
}])
->whereIn('idSolicitud', $r)
->skip($inicio)
->take($elementos)
->orderByRaw("field(idSolicitud, ".implode(',' , $r->toArray()).")")
->get();
What I want is get the last conversation so I use ->first() to get the last. But this return conversation:[] without data, but when I change ->first() to ->get() return all the conversation I don't know what is wrong.