StoreCouponIssueUser.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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\activity\coupon;
  12. use app\model\user\User;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * TODO 优惠券前台用户领取Model
  18. * Class StoreCouponIssueUser
  19. * @package app\model\coupon
  20. */
  21. class StoreCouponIssueUser extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 模型名称
  26. * @var string
  27. */
  28. protected $name = 'store_coupon_issue_user';
  29. /**
  30. * 获取领取人名称头像
  31. * @return \think\model\relation\HasOne
  32. */
  33. public function userInfo()
  34. {
  35. return $this->hasOne(User::class, 'uid', 'uid')->field('uid,nickname,avatar')->bind(['nickname','avatar']);
  36. }
  37. /**
  38. * 添加时间获取器
  39. * @param $value
  40. * @return false|string
  41. */
  42. public function getAddTimeAttr($value)
  43. {
  44. return date('Y-m-d H:i:s', $value);
  45. }
  46. /**
  47. * 领取用户搜索器
  48. * @param Model $query
  49. * @param $value
  50. * @param $data
  51. */
  52. public function searchUidAttr($query, $value, $data)
  53. {
  54. $query->where('uid', $value);
  55. }
  56. /**
  57. * 领取优惠券搜索器
  58. * @param Model $query
  59. * @param $value
  60. * @param $data
  61. */
  62. public function searchIssueCouponIdAttr($query, $value, $data)
  63. {
  64. $query->where('issue_coupon_id', $value);
  65. }
  66. }