Parcourir la source

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

tangyuanwang il y a 1 jour
Parent
commit
a8f7b1e7f6
1 fichiers modifiés avec 16 ajouts et 2 suppressions
  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;
+        }
     }
 }