Sfoglia il codice sorgente

去除不展示图片时的数据

林海涛 1 anno fa
parent
commit
be1b46ada9
1 ha cambiato i file con 19 aggiunte e 1 eliminazioni
  1. 19 1
      app/adminapi/logic/shops/ShopGoodsLogic.php

+ 19 - 1
app/adminapi/logic/shops/ShopGoodsLogic.php

@@ -41,6 +41,15 @@ class ShopGoodsLogic extends BaseLogic
     {
         Db::startTrans();
         try {
+            if(isset($params['custom_attribute_items']) && !empty($params['custom_attribute_items'])){
+                foreach($params['custom_attribute_items'] as &$item){
+                    if(intval($item['img_type']) === 0){
+                        foreach($item['spec_items'] as $k => $v){
+                            unset($item['spec_items'][$k]['spec_img']);
+                        }
+                    }
+                }
+            }
             $params['goods_category_id'] = end($params['goods_category_ids']);
             $model = ShopGoods::create([
                 'delivery_type' => $params['delivery_type'],
@@ -94,7 +103,15 @@ class ShopGoodsLogic extends BaseLogic
     {
         Db::startTrans();
         try {
-           // dd($params);
+            if(isset($params['custom_attribute_items']) && !empty($params['custom_attribute_items'])){
+                foreach($params['custom_attribute_items'] as &$item){
+                    if(intval($item['img_type']) === 0){
+                        foreach($item['spec_items'] as $k => $v){
+                            unset($item['spec_items'][$k]['spec_img']);
+                        }
+                    }
+                }
+            }
             ShopGoods::where('id', $params['id'])->update([
                 'delivery_type' => $params['delivery_type'],
                 'shop_goods_type' => $params['shop_goods_type'],
@@ -154,6 +171,7 @@ class ShopGoodsLogic extends BaseLogic
      */
     public static function delete(array $params): bool
     {
+        ShopGoodSpecsInventory::where('shop_goods_id',$params['id'])->delete();
         return ShopGoods::destroy($params['id']);
     }