StoreCouponUser.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020-05-14
  7. *
  8. *
  9. */
  10. namespace app\common\model\store\coupon;
  11. use app\common\model\BaseModel;
  12. use app\common\model\user\User;
  13. /**
  14. * Class StoreCouponUser
  15. * @package app\common\model\store\coupon
  16. * @author xaboy
  17. * @day 2020-05-14
  18. */
  19. class StoreCouponUser extends BaseModel
  20. {
  21. /**
  22. * @return string
  23. * @author xaboy
  24. * @day 2020-03-30
  25. */
  26. public static function tablePk(): string
  27. {
  28. return 'coupon_user_id';
  29. }
  30. /**
  31. * @return string
  32. * @author xaboy
  33. * @day 2020-03-30
  34. */
  35. public static function tableName(): string
  36. {
  37. return 'store_coupon_user';
  38. }
  39. public function user()
  40. {
  41. return $this->hasOne(User::class, 'uid', 'uid');
  42. }
  43. public function coupon()
  44. {
  45. return $this->hasOne(StoreCoupon::class, 'coupon_id', 'coupon_id');
  46. }
  47. public function product()
  48. {
  49. return $this->hasMany(StoreCouponProduct::class, 'coupon_id', 'coupon_id');
  50. }
  51. }