Get last inserted id in Laravel 5

In Laravel after saving records with Laravel Eloquent you can get last inserted id by getting id property of the same obj from which you have saved.


public function saveUser(){
  $user =new User();
  $user->address="New Delhi";
//Getting last inserted id
  return $user->id;

Leave a Reply

Your email address will not be published. Required fields are marked *