xielin преди 6 години
родител
ревизия
264023e5a0
променени са 1 файла, в които са добавени 17 реда и са изтрити 17 реда
  1. 17 17
      app/Repositories/CmsContentTemplateSetRepository.php

+ 17 - 17
app/Repositories/CmsContentTemplateSetRepository.php

@@ -133,18 +133,16 @@ class CmsContentTemplateSetRepository {
                 'updated_at' => date('Y-m-d H:i:s')
             ];
 
-            if ($advertisement_id){
+            if (empty($advertisement_id)){
+                if (!$this->cmsContentTemplateSet->create($subject)) {
+                    throw new HttpException(500, '添加失败');
+                }
+            }else{
                 $advertisement_ids = $this->cmsContentTemplateSet->where('id',$advertisement_id)->update($subject);
                 if (!$advertisement_ids) {
                     throw new HttpException(500, '更新失败');
                 }
-            }else{
-                if (!$this->cmsContentTemplateSet->create($subject)) {
-                    throw new HttpException(500, '添加失败');
-                }
             }
-
-
     }
 
     /**
@@ -161,15 +159,16 @@ class CmsContentTemplateSetRepository {
                 'created_at' => date('Y-m-d H:i:s'),
                 'updated_at' => date('Y-m-d H:i:s')
             ];
-        if ($floor_id){
+        if (empty($floor_id)){
+            if (!$this->cmsContentTemplateSet->create($subject)) {
+                throw new HttpException(500, '添加失败');
+            }
+        }else {
             $floor_ids = $this->cmsContentTemplateSet->where('id',$floor_id)->update($subject);
             if (!$floor_ids) {
                 throw new HttpException(500, '更新失败');
             }
-        }else {
-            if (!$this->cmsContentTemplateSet->create($subject)) {
-                throw new HttpException(500, '添加失败');
-            }
+
         }
 
     }
@@ -188,15 +187,16 @@ class CmsContentTemplateSetRepository {
                 'created_at' => date('Y-m-d H:i:s'),
                 'updated_at' => date('Y-m-d H:i:s')
             ];
-        if ($category_id){
+        if (empty($category_id)){
+            if (!$this->cmsContentTemplateSet->create($subject)) {
+                throw new HttpException(500, '添加失败');
+            }
+        }else {
             $category_ids = $this->cmsContentTemplateSet->where('id',$category_id)->update($subject);
             if (!$category_ids) {
                 throw new HttpException(500, '更新失败');
             }
-        }else {
-            if (!$this->cmsContentTemplateSet->create($subject)) {
-                throw new HttpException(500, '添加失败');
-            }
+
         }
 
     }