Browse Source

判断修改

durong 5 years ago
parent
commit
ab9535b1ca
1 changed files with 21 additions and 20 deletions
  1. 21 20
      app/Repositories/V2/CmsContentTemplateSetRepository.php

+ 21 - 20
app/Repositories/V2/CmsContentTemplateSetRepository.php

@@ -20,37 +20,38 @@ class CmsContentTemplateSetRepository {
     //banner模板选专题-被使用计数
     //banner模板选专题-被使用计数
     public function countSubject($request)
     public function countSubject($request)
     {
     {
-        if ($request['type'] == 0){
-            $rule = json_decode($request['rule'],true);
-            if ($rule['link_type'] == 1){
-                $templates = $this->cmsSubject->where('id',intval($rule['link_url']))->first();
-                $templates->used_count +=1;
+        if ($request['type'] == 0) {
+            $rule = json_decode($request['rule'], true);
+            if ($rule['link_type'] == 1) {
+                $templates = $this->cmsSubject->where('id', intval($rule['link_url']))->first();
+                $templates->used_count += 1;
                 $templates->save();
                 $templates->save();
             }
             }
-        }else{
-            $subject_id_array = json_decode($request['old_rule'],true);
-            $rule = json_decode($request['rule'],true);
-            if ($subject_id_array['link_type'] == 1 && $rule['link_type'] == 1){//链接方式都为专题
-                if ($subject_id_array['link_url'] != $rule['link_type']){
-                    $templates = $this->cmsSubject->where('id',intval($subject_id_array['link_url']))->first();
+        }
+        if ($request['type'] == 1) {
+            $subject_id_array = json_decode($request['old_rule'], true);
+            $rule = json_decode($request['rule'], true);
+            if ($subject_id_array['link_type'] == 1 && $rule['link_type'] == 1) {//链接方式都为专题
+                if ($subject_id_array['link_url'] != $rule['link_type']) {
+                    $templates = $this->cmsSubject->where('id', intval($subject_id_array['link_url']))->first();
                     $update_template = [
                     $update_template = [
-                        $templates->used_count -=1
+                        $templates->used_count -= 1
                     ];
                     ];
                     $templates->update($update_template);
                     $templates->update($update_template);
 
 
-                    $templates = $this->cmsSubject->where('id',intval($rule['link_type']))->first();
-                    $templates->used_count +=1;
+                    $templates = $this->cmsSubject->where('id', intval($rule['link_type']))->first();
+                    $templates->used_count += 1;
                     $templates->save();
                     $templates->save();
                 }
                 }
-            }elseif ($subject_id_array['link_type'] == 1 && $rule['link_type'] != 1){
-                $templates = $this->cmsSubject->where('id',intval($subject_id_array['link_url']))->first();
+            } elseif ($subject_id_array['link_type'] == 1 && $rule['link_type'] != 1) {
+                $templates = $this->cmsSubject->where('id', intval($subject_id_array['link_url']))->first();
                 $update_template = [
                 $update_template = [
-                    $templates->used_count -=1
+                    $templates->used_count -= 1
                 ];
                 ];
                 $templates->update($update_template);
                 $templates->update($update_template);
-            }elseif ($subject_id_array['link_type'] != 1 && $rule['link_type'] == 1){
-                $templates = $this->cmsSubject->where('id',intval($request['rule']['link_url']))->first();
-                $templates->used_count +=1;
+            } elseif ($subject_id_array['link_type'] != 1 && $rule['link_type'] == 1) {
+                $templates = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
+                $templates->used_count += 1;
                 $templates->save();
                 $templates->save();
             }
             }
         }
         }