How to get last inserted id from table in Laravel

How to get last inserted id from table in Laravel

In this tutorial, we will explain to you about how to get last inserted id from the table in laravel. Sometimes when we need first table reference ID to insert to another table at that time we have to need last inserted ID of the first table.

If you want to get last inserted ID from the table. laravel provides the Eloquent library method such as save(), create(), insertGetId() and getPdo().

So you can see below steps for laravel get last insert id.

Using The save() Method

Using The create() Method

Using The insertGetId() Method

Using The getPdo() Method

Please follow and like us: