ArticleCategory.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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\model\article;
  12. use crmeb\traits\ModelTrait;
  13. use crmeb\basic\BaseModel;
  14. use think\Model;
  15. /**
  16. * 文章分类Model
  17. * Class ArticleCategory
  18. * @package app\model\article
  19. */
  20. class ArticleCategory extends BaseModel
  21. {
  22. use ModelTrait;
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'article_category';
  33. /**
  34. * 分类状态搜索器
  35. * @param Model $query
  36. * @param $value
  37. * @param $data
  38. */
  39. public function searchStatusAttr($query, $value, $data)
  40. {
  41. if ($value !== '') $query->where('status', $value);
  42. }
  43. /**
  44. * 分类名称搜索器
  45. * @param Model $query
  46. * @param $value
  47. * @param $data
  48. */
  49. public function searchTitleAttr($query, $value, $data)
  50. {
  51. if ($value !== '') $query->where('title', 'like', '%' . $value . '%');
  52. }
  53. /**
  54. * 隐藏搜索器
  55. * @param Model $query
  56. * @param $value
  57. * @param $data
  58. */
  59. public function searchHiddenAttr($query, $value, $data)
  60. {
  61. $query->where('hidden', $value);
  62. }
  63. /**
  64. * 删除搜索器
  65. * @param Model $query
  66. * @param $value
  67. * @param $data
  68. */
  69. public function searchIsDelAttr($query, $value, $data)
  70. {
  71. $query->where('is_del', $value);
  72. }
  73. }