ProductGroupBuying.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\model\store\product;
  12. use app\common\model\BaseModel;
  13. use app\common\model\system\merchant\Merchant;
  14. class ProductGroupBuying extends BaseModel
  15. {
  16. /**
  17. * TODO
  18. * @return string
  19. * @author Qinii
  20. * @day 1/7/21
  21. */
  22. public static function tablePk(): string
  23. {
  24. return 'group_buying_id';
  25. }
  26. /**
  27. * TODO
  28. * @return string
  29. * @author Qinii
  30. * @day 1/7/21
  31. */
  32. public static function tableName(): string
  33. {
  34. return 'store_product_group_buying';
  35. }
  36. public function getStopTimeAttr()
  37. {
  38. return date('Y-m-d H:i:s',$this->end_time);
  39. }
  40. public function groupUser()
  41. {
  42. return $this->hasMany(ProductGroupUser::class,'group_buying_id','group_buying_id');
  43. }
  44. public function initiator()
  45. {
  46. return $this->hasOne(ProductGroupUser::class,'group_buying_id','group_buying_id')->where('is_initiator',1);
  47. }
  48. public function productGroup()
  49. {
  50. return $this->hasOne(ProductGroup::class,'product_group_id','product_group_id');
  51. }
  52. public function merchant()
  53. {
  54. return $this->hasOne(Merchant::class,'mer_id','mer_id');
  55. }
  56. public function searchEndTimeAttr($query,$value)
  57. {
  58. $query->where('end_time','<=',$value);
  59. }
  60. public function searchStatusAttr($query,$value)
  61. {
  62. $query->where('status',$value);
  63. }
  64. public function searchIsDelAttr($query,$value)
  65. {
  66. $query->where('is_del',$value);
  67. }
  68. public function searchProductGroupIdAttr($query,$value)
  69. {
  70. $query->where('product_group_id',$value);
  71. }
  72. public function searchGroupBuyingIdAttr($query,$value)
  73. {
  74. $query->where('group_buying_id',$value);
  75. }
  76. }