ArticleCategoryController.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\api\controller\publics;
  3. use app\models\article\ArticleCategory;
  4. use app\Request;
  5. use crmeb\services\UtilService;
  6. /**
  7. * 文章分类类
  8. * Class ArticleCategoryController
  9. * @package app\api\controller\publics
  10. */
  11. class ArticleCategoryController
  12. {
  13. /**
  14. * 文章分类列表
  15. * @return mixed
  16. * @throws \think\db\exception\DataNotFoundException
  17. * @throws \think\db\exception\ModelNotFoundException
  18. * @throws \think\exception\DbException
  19. */
  20. public function lst(Request $request)
  21. {
  22. list($id) = UtilService::postMore([
  23. ['id',0],//分类父id编号
  24. ], $request, true);
  25. if ($id>0){
  26. $cateInfo = ArticleCategory::getIdArticleCategoryWithChildren($id);
  27. }else{
  28. $cateInfo = ArticleCategory::getArticleCategory();
  29. }
  30. if($cateInfo) $cateInfo = $cateInfo->toArray();
  31. else $cateInfo = [];
  32. array_unshift($cateInfo,['id'=>0,'title'=>'热门']);
  33. return app('json')->successful($cateInfo);
  34. }
  35. }