I am starting to study Laravel 5.5 and I would like to obtain the last 5 records that have been made in a table of my database
I have been looking and found the last() but it only allows me to get one and I would like to get 5
$user= Users::all();
return view('users.index')->with('users', $user->last());
Using the method
latest()
to sort them from newest to oldest, and then taking 5 items withtake()
: