в итоге получилось следующее, вроде как и не гемморно вовсе
DB::select(DB::raw('SELECT from_id, MAX(id) as updated
FROM (SELECT from_id, id
FROM messages
WHERE to_id = 1
UNION SELECT to_id, id
FROM messages
WHERE from_id = 1
ORDER BY id DESC) as talks
GROUP BY from_id
ORDER BY updated DESC'));