| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\api\controller\publics;
- use app\models\article\ArticleCategory;
- use app\Request;
- use crmeb\services\UtilService;
- /**
- * 文章分类类
- * Class ArticleCategoryController
- * @package app\api\controller\publics
- */
- class ArticleCategoryController
- {
- /**
- * 文章分类列表
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function lst(Request $request)
- {
- list($id) = UtilService::postMore([
- ['id',0],//分类父id编号
- ], $request, true);
- if ($id>0){
- $cateInfo = ArticleCategory::getIdArticleCategoryWithChildren($id);
- }else{
- $cateInfo = ArticleCategory::getArticleCategory();
- }
- if($cateInfo) $cateInfo = $cateInfo->toArray();
- else $cateInfo = [];
- array_unshift($cateInfo,['id'=>0,'title'=>'热门']);
- return app('json')->successful($cateInfo);
- }
- }
|