ArticleCategoryDao.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\article;
  12. use app\dao\BaseDao;
  13. use app\model\article\ArticleCategory;
  14. /**
  15. * 文章分类
  16. * Class ArticleCategoryDao
  17. * @package app\dao\article
  18. */
  19. class ArticleCategoryDao extends BaseDao
  20. {
  21. /**
  22. * 设置模型
  23. * @return string
  24. */
  25. protected function setModel(): string
  26. {
  27. return ArticleCategory::class;
  28. }
  29. /**
  30. * 获取文章列表
  31. * @param array $where
  32. * @param int $page
  33. * @param int $limit
  34. * @return mixed
  35. */
  36. public function getList(array $where, int $page, int $limit)
  37. {
  38. return $this->search($where)->page($page, $limit)->order('sort desc,id desc')->select()->toArray();
  39. }
  40. /**
  41. * 前台获取文章分类
  42. * @return array
  43. * @throws \think\db\exception\DataNotFoundException
  44. * @throws \think\db\exception\DbException
  45. * @throws \think\db\exception\ModelNotFoundException
  46. */
  47. public function getArticleCategory()
  48. {
  49. return $this->search(['hidden'=>0,'is_del'=>0,'status'=>1])
  50. ->order('sort DESC')
  51. ->field('id,title')
  52. ->select()->toArray();
  53. }
  54. }