duqinya před 6 roky
rodič
revize
599806ba6b
1 změnil soubory, kde provedl 15 přidání a 10 odebrání
  1. 15 10
      app/Repositories/CmsContentTemplateSetRepository.php

+ 15 - 10
app/Repositories/CmsContentTemplateSetRepository.php

@@ -220,9 +220,9 @@ class CmsContentTemplateSetRepository {
         $templateSet = $this->cmsContentTemplateSet->where('tpl_id',$request['tpl_id'])->select('id','status')->get();
         $tem_array = $templateSet->toArray();
         $template = $this->cmsContentTemplate->select('id','city_name','city_id','title','apply_type','is_open','status')->where('id',$request['tpl_id'])->first();
-        if ($template->is_open == 0){
-            throw new HttpException(500, '请先将状态开启之后再发布');
-        }
+//        if ($template->is_open == 0){
+//            throw new HttpException(500, '请先将状态开启之后再发布');
+//        }
         $where = [
             'city_id'=>$template->city_id,
             'title'=>$template->title,
@@ -236,9 +236,18 @@ class CmsContentTemplateSetRepository {
             }
         }
 
-        $update_open = $this->cmsContentTemplate->whereIn('id', $update_is_open_ids)->delete();
-        if (!$update_open) {
-            throw new HttpException(500, '删除失败,请重试');
+        if ($update_is_open_ids){
+            $update_open = $this->cmsContentTemplate->whereIn('id', $update_is_open_ids)->delete();
+            if (!$update_open) {
+                throw new HttpException(500, '删除失败,请重试');
+            }
+
+            $update_open = $this->cmsContentTemplateSet->whereIn('tpl_id', $update_is_open_ids)->update(['status' => 0]);
+
+            if (!$update_open) {
+                throw new HttpException(500, '修改失败,请重试');
+            }
+
         }
 
         $update_tpl = $this->cmsContentTemplate->where('id', $request['tpl_id'])->update(['status' => 1]);
@@ -246,11 +255,7 @@ class CmsContentTemplateSetRepository {
             throw new HttpException(500, '修改失败,请重试');
         }
 
-        $update_open = $this->cmsContentTemplateSet->whereIn('tpl_id', $update_is_open_ids)->update(['status' => 0]);
 
-        if (!$update_open) {
-            throw new HttpException(500, '修改失败,请重试');
-        }
         $res = $this->cmsContentTemplateSet->where('tpl_id',$request['tpl_id'])->update(['status'=>1]);
 
         if (!$res){