Laravel: How to get last N entries from DB

Chidiebere Chukwudi - May 21 '21 - - Dev Community

I just added an answer to this question on stackoverflow.

Maybe I should write a little note on this ?!

Imagine a situation where you want to get the latest record of data from the request header that was just inserted into the database:

$noOfFilesUploaded = count( $request->pic );// e.g 4
$model = new Model
$model->latest()->take($noOfFilesUploaded); 

This way your take() helper function gets the number of array data that was…

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player