How to get last inserted id in Laravel 5.7 Using save()?

Posted by LaravelIndia - 1 year ago

Example 1: Using save()

public function craeteNewProduct(){
    $product_data =new Products();
    $product_data->name = "Admin XYZ";
    $product_data->desc = "product Description";
    $product_data->save();
    return $product_data->id;

}