SystemConfig.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 SystemConfig
  18. * @package app\model\system\config
  19. */
  20. class SystemConfig 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';
  33. /**
  34. * 菜单名搜索器
  35. * @param Model $query
  36. * @param $value
  37. */
  38. public function searchMenuNameAttr($query, $value)
  39. {
  40. if (is_array($value)) {
  41. $query->whereIn('menu_name', $value);
  42. } else {
  43. $query->where('menu_name', $value);
  44. }
  45. }
  46. /**
  47. * tab id 搜索
  48. * @param Model $query
  49. * @param $value
  50. */
  51. public function searchTabIdAttr($query, $value)
  52. {
  53. $query->where('config_tab_id', $value);
  54. }
  55. /**
  56. * 状态搜索器
  57. * @param Model $query
  58. * @param $value
  59. */
  60. public function searchStatusAttr($query, $value)
  61. {
  62. $query->where('status', $value ?: 1);
  63. }
  64. /**
  65. * value搜索器
  66. * @param Model $query
  67. * @param $value
  68. */
  69. public function searchValueAttr($query, $value)
  70. {
  71. $query->where('value', $value);
  72. }
  73. }