ZxcZxc123 2 лет назад
Родитель
Сommit
7c5861732a
2 измененных файлов с 25 добавлено и 25 удалено
  1. 24 24
      app/model/api/EducationModel.php
  2. 1 1
      app/system/controller/Index.php

+ 24 - 24
app/model/api/EducationModel.php

@@ -18,30 +18,30 @@ class EducationModel extends Model
         return new self;
     }
 
-//    /**
-//     * 获取所有分类
-//     *
-//     * @return mixed
-//     */
-//    public function getCate()
-//    {
-//        $items = $this->table(self::CATE_TABLE_NAME)
-//            ->where(['status' => 'Y'])
-//            ->order('sort', 'asc')
-//            ->column('id,pid,name,sort', 'id');
-//
-//        $tree = array();
-//        foreach ($items as $key => $item) {
-//            $items[$key]['oriName'] = $item['name'];
-//            if (isset ($items [$item ['pid']])) {
-//                $items [$item ['pid']] ['children'] [$item ['id']] = &$items [$item ['id']];
-//            } else {
-//                $tree [$item ['id']] = &$items [$item ['id']];
-//            }
-//        }
-//
-//        return  array_values($tree);
-//    }
+    /**
+     * 获取所有分类
+     *
+     * @return mixed
+     */
+    public function getCate()
+    {
+        $items = $this->table(self::CATE_TABLE_NAME)
+            ->where(['status' => 'Y'])
+            ->order('sort', 'asc')
+            ->column('id,pid,name,sort', 'id');
+
+        $tree = array();
+        foreach ($items as $key => $item) {
+            $items[$key]['oriName'] = $item['name'];
+            if (isset ($items [$item ['pid']])) {
+                $items [$item ['pid']] ['children'] [$item ['id']] = &$items [$item ['id']];
+            } else {
+                $tree [$item ['id']] = &$items [$item ['id']];
+            }
+        }
+
+        return  array_values($tree);
+    }
 
 //    public function getGrList($userId)
 //    {

+ 1 - 1
app/system/controller/Index.php

@@ -58,6 +58,6 @@ class Index extends AuthController
     {
         $educationModel = new EducationModel();
         $cateList = $educationModel->getCate();
-        return json($cateList);
+        return app('json')->success($cateList);
     }
 }