to groupby the latest record, you can use latest & unique methods like this:

PHOTO EMBED

Sun Oct 02 2022 23:07:58 GMT+0000 (Coordinated Universal Time)

Saved by @lusiba #php

public function lastMessages() {
 return $this->hasMany('App\Message', 'recipient_id')->latest()->get()->unique('author_id')
content_copyCOPY