Cześć, mam taki kod
$messages = ChatMessage::orderBy('created_at', 'asc')
->where('resource_id', $resourceId)
->where('resource_type', $resourceType)
->get()
->groupBy(function ($group) {
return Carbon::parse($group->created_at)->format('Y-m-d');
});
return ChatMessagesResource::collection($messages);
pobiera rekordy pogrupowane po dacie. Ogólnie działa to prawidłowo jednak chciałbym do tego dodać paginację ponieważ pobieranie wszystkich wiadomości w konwersacji jednocześnie nie jest zbyt wydajne