Laravel: How to get last N entries from DB
Chidiebere Chukwudi

Chidiebere Chukwudi @jovialcore

About: Software Developer. php| laravel | cakephp | vuejs/Nuxt | wordpress | Bootstrap | Tailwind

Location:
Nigeria
Joined:
Jan 10, 2018

Laravel: How to get last N entries from DB

Publish Date: May 21 '21
0 0

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…

Comments 0 total

    Add comment