|
@@ -13,29 +13,13 @@ class EducationController
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 获取所有分类
|
|
|
|
|
- * @return \think\response\Json
|
|
|
|
|
|
|
+ * 获取所有分类列表
|
|
|
*/
|
|
*/
|
|
|
- public function getCate()
|
|
|
|
|
|
|
+ public function getCateList()
|
|
|
{
|
|
{
|
|
|
- $items = Db::table('table_education_cate')
|
|
|
|
|
- ->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']];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-// $data = array_values($tree);
|
|
|
|
|
-// $msg = '获取分类成功';
|
|
|
|
|
- return app('json') -> success($tree);
|
|
|
|
|
|
|
+ $educationModel = new EducationModel();
|
|
|
|
|
+ $cateList = $educationModel->getCate();
|
|
|
|
|
+ return app('json')->success($cateList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|