How to display pagination Laravel?

How to display pagination if this record?

$messages = DB::table('dialog_messages')
->leftJoin('user_attributes','user_attributes.user_id','=','dialog_messages.user_id')
->select('user_attributes.avatar','user_attributes.fullname','dialog_messages.replay','dialog_messages.created_at','user_attributes.user_id','dialog_messages.id')
->where('dialog_messages.dialog_id','=', $request->dialog_id)
->orderBy('dialog_messages.id','DESC')->paginate(15)->reverse()->values();

if you take away

->reverse()->values()
it displays

current_page: 1
data: [,...]
0: {avatar: "uploads/users/avatars/1-2020-02-05-223757.jpg", "fullname": "Maxim Drozdov", replay: "111111",...}
1: {avatar: "uploads/users/avatars/1-2020-02-05-223757.jpg", "fullname": "Maxim Drozdov",...}
first_page_url: "http://bet.litesites.ru/profile/dialogs/messages?page=1"
from: 1
last_page: 3
last_page_url: "http://bet.litesites.ru/profile/dialogs/messages?page=3"
next_page_url: "http://bet.litesites.ru/profile/dialogs/messages?page=2"
path: "http://bet.litesites.ru/profile/dialogs/messages"
per_page: 15
prev_page_url: null
to: 15
total: 44
April 7th 20 at 10:57
1 answer
April 7th 20 at 10:59
did

$data = $messages->reverse()->values();
return response()->json([
 'messages' => $data,
 'page' => $messages->currentPage(),
]);

Find more questions by tags Laravel