Im building the chat section of my app with vueJs and laravel backend. I want to fetch my messages grouped by days. So when messages display, I want them to look something like this.
`Today
**All messages sent and received today, ordered by time**
Yesterday
**Yesterday's messages**
9/12/2018
**Messages for that day**
In my Chat model, I wrote an accessor for this like so;
public function getMessagesAttribute(){ return $this ->groupBy(function($q){ return $q->created_at->format('Y-m-d'); });
However, this does not give anything different from what I got when I use orderBy('created_at', 'ASC') in the controller. I will appreciate any assistance/guidance to achieve what I want please.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire