UserLevel.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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\user;
  12. use app\model\system\SystemUserLevel;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\model;
  16. /**
  17. * Class UserLevel
  18. * @package app\model\user
  19. */
  20. class UserLevel 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 = 'user_level';
  33. public function levelInfo()
  34. {
  35. return $this->hasOne(SystemUserLevel::class, 'id', 'level_id');
  36. }
  37. /**
  38. * 用户uid
  39. * @param Model $query
  40. * @param $value
  41. */
  42. public function searchUidAttr($query, $value)
  43. {
  44. $query->where('uid', $value);
  45. }
  46. /**
  47. * 是否永久
  48. * @param Model $query
  49. * @param $value
  50. */
  51. public function searchIsForeverAttr($query, $value)
  52. {
  53. $query->where('is_forever', $value);
  54. }
  55. /**
  56. * 过期时间
  57. * @param Model $query
  58. * @param $value
  59. */
  60. public function searchValidTimeAttr($query, $value)
  61. {
  62. $query->where('valid_time', '>', $value);
  63. }
  64. /**
  65. * 状态
  66. * @param Model $query
  67. * @param $value
  68. */
  69. public function searchStatusAttr($query, $value)
  70. {
  71. $query->where('status', $value);
  72. }
  73. /**
  74. * 是否通知
  75. * @param Model $query
  76. * @param $value
  77. */
  78. public function searchRemindAttr($query, $value)
  79. {
  80. $query->where('remind', $value);
  81. }
  82. /**
  83. * 是否删除
  84. * @param Model $query
  85. * @param $value
  86. */
  87. public function searchIsDelAttr($query, $value)
  88. {
  89. $query->where('is_del', $value);
  90. }
  91. }