1Jz Wiring Harness Today we are going to share How to get Last Record from Table in Laravel with example. There are several way to get latest inserted record from table in Laravel. But here we use latest()->first() and orderBy(). method to get last record table Laravel project. This is very simple to get last inserted rows from the table in Laravel. Normally I use order by clause along with limit 1 to get last row from the table using MySQL query and same you can do in Laravel. Here you find the easy and simple examples to get last record which is inserted in last time from table in Laravel with easy methods.
1. Using Order By in Laravel
4 2 Vortec Engine Diagram Here we used orderBy() that belong to id, it will always return last record from table.
$lastestRecord = DB::table('files')->orderBy('id', 'DESC')->first();
2. Using latest method
741Opamp Amplifiercircuit Circuit Diagram Seekiccom The latest method return last record which is created in last time and the the first get the one record.
$lastestRecord = DB::table('files')->latest()->first();
2008 Dodge Charger Fuse Box Diagram I hope these all above examples will help you to fetch last record of table in laravel.