thetanaz's avatar

Why isn't the reverse() working in this method?

I'm trying to reverse the messages so the newest one can be at the bottom, but I think either the pagination or something else is interferring :

Even with the reverse()->values being called on the messages of each conversation I'm still getting the newest messages above the older ones. I can easily fix this in my react front end , but I'm wondering what it is that I'm missing here.

0 likes
4 replies
thetanaz's avatar

@Snapey What I did instead was $query->orderBy('created_at', 'asc')->take(-20); I changed the order to ascending and took the last 20, but I will investigate your earlier comment about limiting the messages to 20 tomorrow, I will make a factory for some conversations and messages to see the behavior and if it indeed limits it to 20 for all conversations combined I will fix it. Thanks!

thetanaz's avatar

I've decided that this would be the last version of the method, and I would just reverse the content in the front-end react component, however I'm not experiencing the issue @snapey described, I'm getting 20 messages per conversation and not 20 in total, so everything seems to be working fine.

Please or to participate in this conversation.