jeudi 2 novembre 2017

How to find last inserted id, when using laravel firstOrNew new method to inser the data

Am using laravel firstOrNew method to insert the data . when data is not present in the table it will insert the data. after inserting the data am unable to get the last inserted id.

ex:

   $user = User::firstOrNew(['id'=>1]);
   $user->name='prasanna';
   $user->save();
   dd($user->id); //it prints true,  here i need last inserted  id 



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lIWcXU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire