wzq před 5 roky
rodič
revize
8d602d63e6
1 změnil soubory, kde provedl 19 přidání a 13 odebrání
  1. 19 13
      app/Repositories/CategoryRepository.php

+ 19 - 13
app/Repositories/CategoryRepository.php

@@ -20,19 +20,25 @@ class CategoryRepository {
     //列表
     public function lists($request)
     {
-        $categories =  $this->category->select('id', 'name', 'img')->limit(50)->get()->toArray();
-        $data = [
-            [
-                'id' => -2,
-                'name' => '热门',
-                'img' => config('customer.category_hot_img')
-            ],
-            [
-                'id' => -1,
-                'name' => '我的话题',
-                'img' => config('customer.category_my_img')
-            ]
-        ];
+        $where = [];
+        if(isset($request['is_suggest']) && $request['is_suggest'] == 1){
+            $where [] = ['is_suggest', 1];
+            $data = [];
+        }else{
+            $data = [
+                [
+                    'id' => -2,
+                    'name' => '热门',
+                    'img' => config('customer.category_hot_img')
+                ],
+                [
+                    'id' => -1,
+                    'name' => '我的话题',
+                    'img' => config('customer.category_my_img')
+                ]
+            ];
+        }
+        $categories =  $this->category->select('id', 'name', 'img')->where($where)->limit(50)->get()->toArray();
         return array_merge($data, $categories);
     }
     //获取多个话题