I'm trying to get the last inserted ID in the database after a firstOrCreate() call. I have copied my code below:
$booking->firstOrCreate(array_slice($reserve->whereId($payment->reserved_place_id)->first()->toArray(), 0, 24))->save();
How can I get the last ID inserted?
I have looked at the other Laravel requests to get last insert ID but I believe this instance is different because they are not using firstOrCreate().
Thanks in advance.
firstOrCreate()
method returns Model. So you can simply save it to some variable and then get the model's ID.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With