SystemConfigTab.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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\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. /**
  79. * @param $query
  80. * @param $value
  81. */
  82. public function searchIsStoreAttr($query, $value)
  83. {
  84. if ($value !== '') {
  85. $query->where('is_store', $value);
  86. }
  87. }
  88. }