Ver Fonte

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/news_producer

AI há 3 semanas atrás
pai
commit
0db6c2cfa3
1 ficheiros alterados com 5 adições e 2 exclusões
  1. 5 2
      app/JsonRpc/NewsService.php

+ 5 - 2
app/JsonRpc/NewsService.php

@@ -65,9 +65,12 @@ class NewsService implements NewsServiceInterface
     private function findMatchedCategories($search)
     {
         if ($search) {
-            return Category::where('name', 'like', "%{$search}%")->get();
+            return Category::where('name', 'like', "%{$search}%")
+                ->orderBy('updated_at', 'desc')
+                ->get();
         }
-        return Category::all();
+        return Category::orderBy('updated_at', 'desc') // 按 updated_at 字段倒序排序
+        ->get();
     }
 
     private function findAllParents($categories)