duqinya лет назад: 6
Родитель
Сommit
d29017244c
1 измененных файлов с 12 добавлено и 1 удалено
  1. 12 1
      app/Repositories/CmsContentTemplateSetRepository.php

+ 12 - 1
app/Repositories/CmsContentTemplateSetRepository.php

@@ -417,8 +417,19 @@ class CmsContentTemplateSetRepository {
 
     public function getTemplate($cityId)
     {
-        return $this->cmsContentTemplate->select('id','title','apply_type')->where(['city_id'=>$cityId,'deleted_at'=>null])->distinct('title')->orderBy('apply_type','asc')->get();
+        $template = $this->cmsContentTemplate->select('id','title','apply_type')->where(['city_id'=>$cityId,'deleted_at'=>null])->orderBy('apply_type','asc')->get();
 
+        $templates = $template->toArray();
+            $tmp_arr = array();
+            foreach($templates as $key => $val) {
+                if(in_array($val['title'],$tmp_arr)) {  //搜索$val['title']是否在$tmp_arr数组中存在,若存在返回true
+                    unset($templates[$key]);
+                } else {
+                    $tmp_arr[] = $val['title'];
+                }
+            }
+            sort($templates);
+            return $templates;
     }
 
     public function templateSetDelete($request)