SystemUserLevel.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. /**
  16. * 系统等级设置模型
  17. * Class SystemUserLevel
  18. * @package app\model\system
  19. */
  20. class SystemUserLevel 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_user_level';
  33. /**
  34. * 时间获取器
  35. * @param $value
  36. * @return false|string
  37. */
  38. public function getAddTimeAttr($value)
  39. {
  40. return date('Y-m-d H:i:s', (int)$value);
  41. }
  42. /**
  43. * 优惠比例获取器
  44. * @param $value
  45. * @return int
  46. */
  47. public function getDiscountAttr($value)
  48. {
  49. return (int)$value;
  50. }
  51. /**
  52. * 是否展示
  53. * @param Model $query
  54. * @param $value
  55. */
  56. public function searchIsShowAttr($query, $value)
  57. {
  58. $query->where('is_show',$value);
  59. }
  60. /**
  61. * 是否删除搜索器
  62. * @param Model $query
  63. * @param $value
  64. * @param $data
  65. */
  66. public function searchIsDelAttr($query, $value)
  67. {
  68. $query->where('is_del', $value ?? 0);
  69. }
  70. /**
  71. * @param Model $query
  72. * @param $value
  73. */
  74. public function searchTitleAttr($query, $value)
  75. {
  76. $query->where('title','LIKE', "%$value%");
  77. }
  78. }