online software programming courses

How to get last N entries from DB | Laravel

To get the first or last 10 entries from laravel eloquent model you can like this. 

Example code

Model::orderBy('id', 'desc')->take(10)->get();

Get any last 10 entries 

Model::latest()->take(10)->get();

To get the latest post or recent post 

Model::orderBy('id', 'desc')->limit(10)->get();