Browse Source

去掉排序

duqinya 6 years ago
parent
commit
1d136e1459
1 changed files with 17 additions and 7 deletions
  1. 17 7
      app/Repositories/CmsContentTemplateSetRepository.php

+ 17 - 7
app/Repositories/CmsContentTemplateSetRepository.php

@@ -421,16 +421,26 @@ class CmsContentTemplateSetRepository {
 
     public function getTemplate($cityId)
     {
-        $template = $this->cmsContentTemplate->select('id','status','title','apply_type')->where(['city_id'=>$cityId,'deleted_at'=>null])->orderBy('apply_type','asc')->get();
-        $templates = $template->toArray();
-            foreach($templates as $key => $val) {
+        $group = $this->cmsContentTemplate->select('id','status','title','apply_type')->where(['city_id'=>$cityId,'deleted_at'=>null,'apply_type'=>0])->get();//->orderBy('apply_type','asc')
+        $groups = $group->toArray();
+        if (count($groups)>1){
+            foreach($groups as $key => $val) {
                 if ($val['status'] == 1) {
-                    unset($templates[$key]);
+                    unset($groups[$key]);
                 }
             }
-
-        array_multisort(array_column($templates,'apply_type'),SORT_ASC,$templates);
-
+        }
+        $market = $this->cmsContentTemplate->select('id','status','title','apply_type')->where(['city_id'=>$cityId,'deleted_at'=>null,'apply_type'=>1])->get();//->orderBy('apply_type','asc')
+        $markets = $market->toArray();
+        if (count($markets)>1){
+            foreach($markets as $key => $val) {
+                if ($val['status'] == 1) {
+                    unset($markets[$key]);
+                }
+            }
+        }
+        $templates = array_merge($groups,$markets);
+        
         return $templates;
     }