I am performing a database operation with "Eloquent ORM in Laravel". I just want to take the last insert id (not the maximum id) in the database.
I searched to get last insert id in laravel Eloquent ORM, I got following link (Laravel, get last insert id using Eloquent) that is refer to get last insert id from following function "$data->save()".
But I need to get
"Model::insert($data)";
My Query:
$insert = Product::insert($alldata);
if ($insert) {
return response()->json([
'success' => 'Ürün başarıyla Eklendi.',
'id' => ???????
]);
}
How can I retrieve the last inserted id?