Category.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\model\article;
  13. use app\common\model\BaseModel;
  14. /**
  15. * 文章分类模型
  16. * Class Category
  17. * @package app\common\model
  18. */
  19. class Category extends BaseModel
  20. {
  21. // 定义表名
  22. protected $name = 'article_category';
  23. // 定义主键
  24. protected $pk = 'category_id';
  25. /**
  26. * 分类详情
  27. * @param int $categoryId
  28. * @return static|null
  29. */
  30. public static function detail(int $categoryId)
  31. {
  32. return static::get($categoryId);
  33. }
  34. /**
  35. * 获取列表
  36. * @param array $where
  37. * @return \think\Collection
  38. * @throws \think\db\exception\DataNotFoundException
  39. * @throws \think\db\exception\DbException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. */
  42. public function getList(array $where = [])
  43. {
  44. return $this->where($where)
  45. ->order(['sort', $this->getPk()])
  46. ->select();
  47. }
  48. }