Procházet zdrojové kódy

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

tangyuanwang před 1 dnem
rodič
revize
a8f7b1e7f6
1 změnil soubory, kde provedl 16 přidání a 2 odebrání
  1. 16 2
      app/Models/Manager/WashConfig/ControlGoods.php

+ 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;
+        }
     }
 }