UserSign.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\model;
  15. /**
  16. * Class UserSign
  17. * @package app\model\user
  18. */
  19. class UserSign extends BaseModel
  20. {
  21. use ModelTrait;
  22. /**
  23. * 数据表主键
  24. * @var string
  25. */
  26. protected $pk = 'id';
  27. /**
  28. * 模型名称
  29. * @var string
  30. */
  31. protected $name = 'user_sign';
  32. /**
  33. * 用户uid
  34. * @param Model $query
  35. * @param $value
  36. */
  37. public function searchUidAttr($query, $value)
  38. {
  39. if (is_array($value))
  40. $query->whereIn('uid', $value);
  41. else
  42. $query->where('uid', $value);
  43. }
  44. /**
  45. * id
  46. * @param Model $query
  47. * @param $value
  48. */
  49. public function searchIdAttr($query, $value)
  50. {
  51. if (is_array($value))
  52. $query->whereIn('id', implode(',', $value));
  53. else
  54. $query->where('id', $value);
  55. }
  56. /**
  57. * 时间
  58. * @param Model $query
  59. * @param $value
  60. */
  61. public function searchAddTimeAttr($query, $value)
  62. {
  63. if (is_string($value)) $query->whereTime('add_time', $value);
  64. if (is_array($value) && count($value) == 2) $query->whereTime('add_time', 'BETWEEN', $value);
  65. }
  66. }