Эх сурвалжийг харах

【智价云】 清洗配置连表删除更新

tangyuanwang 1 өдөр өмнө
parent
commit
a8f7b1e7f6

+ 16 - 2
app/Models/Manager/WashConfig/ControlGoods.php

@@ -196,7 +196,21 @@ class ControlGoods extends Model
         if (!$ControlGoods) {
             return false;
         }
-        $ControlGoods->delete();
-        return true;
+        DB::beginTransaction();
+        try {
+            $ControlGoodsCompanyModel = new ControlGoodsCompanyModel();
+            $company_id_log = $ControlGoodsCompanyModel->where('control_product_logid', $ControlGoods->id)->get();
+            if (!empty($company_id_log)) {
+                $ControlGoodsCompanyModel->where('control_product_logid', $ControlGoods->id)->delete();
+            }
+            $ControlGoods->delete();
+            DB::commit();
+            return true;
+            // 成功处理...
+        } catch (\Exception $e) {
+            DB::rollBack();
+            // 错误处理...
+            return false;
+        }
     }
 }