SystemConfigTab.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 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\system\config;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. /**
  16. * 配置分类模型
  17. * Class SystemConfigTab
  18. * @package app\model\system\config
  19. */
  20. class SystemConfigTab 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 = 'system_config_tab';
  33. /**
  34. * 状态搜索器
  35. * @param Model $query
  36. * @param $value
  37. */
  38. public function searchStatusAttr($query, $value)
  39. {
  40. if ($value != '') {
  41. $query->where('status', $value);
  42. }
  43. }
  44. /**
  45. * pid搜索器
  46. * @param Model $query
  47. * @param $value
  48. */
  49. public function searchPidAttr($query, $value)
  50. {
  51. if (is_array($value)) {
  52. $query->whereIn('pid', $value);
  53. } else {
  54. $value && $query->where('pid', $value);
  55. }
  56. }
  57. /**
  58. * 类型搜索器
  59. * @param Model $query
  60. * @param $value
  61. */
  62. public function searchTypeAttr($query, $value)
  63. {
  64. $query->where('status', 1);
  65. if ($value > -1) {
  66. $query->where(['type' => $value, 'pid' => 0]);
  67. }
  68. }
  69. /**
  70. * 分类名称搜索器
  71. * @param Model $query
  72. * @param $value
  73. */
  74. public function searchTitleAttr($query, $value)
  75. {
  76. $query->whereLike('title', '%' . $value . '%');
  77. }
  78. }