浏览代码

按降序排列

durong 5 年之前
父节点
当前提交
c213f79da6
共有 2 个文件被更改,包括 17 次插入5 次删除
  1. 16 4
      app/Repositories/CmsContentTemplateSetRepository.php
  2. 1 1
      app/Repositories/CmsSubjectRepository.php

+ 16 - 4
app/Repositories/CmsContentTemplateSetRepository.php

@@ -139,7 +139,10 @@ class CmsContentTemplateSetRepository
                 foreach ($request_rule as $k => $v) {
                     if (isset($v['link_type']) && $v['link_type'] == 1) {
                         $templates = $this->cmsSubject->where('id', intval($v['link_url']))->first();
-                        $templates->used_count += 1;
+                        if ($templates == null) {
+                            $templates = new CmsSubject();
+                            $templates->used_count += 1;
+                        }
                         $templates->save();
                     }
                 }
@@ -190,7 +193,10 @@ class CmsContentTemplateSetRepository
                 $templates->update($update_template);
 
                 $templates = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
-                $templates->used_count += 1;
+                if ($templates == null) {
+                    $templates = new CmsSubject();
+                    $templates->used_count += 1;
+                }
                 $templates->save();
             }
         } elseif ($subject_id_array['link_type'] == 1 && $request['rule']['link_type'] != 1) {
@@ -282,7 +288,10 @@ class CmsContentTemplateSetRepository
         if (empty($floor_id)) {
             if ($request['rule']['link_type'] == 1) {
                 $templates = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
-                $templates->used_count += 1;
+                if ($templates == null){
+                    $templates = new CmsSubject();
+                    $templates->used_count += 1;
+                }
                 $templates->save();
             }
             if (!$this->cmsContentTemplateSet->create($subject)) {
@@ -315,7 +324,10 @@ class CmsContentTemplateSetRepository
         if (empty($category_id)) {
             if ($request['rule']['link_type'] == 1) {
                 $templates = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
-                $templates->used_count += 1;
+                if ($templates == null){
+                    $templates = new CmsSubject();
+                    $templates->used_count += 1;
+                }
                 $templates->save();
             }
 

+ 1 - 1
app/Repositories/CmsSubjectRepository.php

@@ -36,7 +36,7 @@ class CmsSubjectRepository {
             $where[] = ['used_mall', '=', $request['used_mall']];
         }
 
-        return $this->cmsSubject->where($where)->orderBy('id', 'asc')->paginate($perPage);
+        return $this->cmsSubject->where($where)->orderBy('id', 'desc')->paginate($perPage);
 
     }