CouponGoods.php 787 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class CouponGoods extends Model
  6. {
  7. protected $table = 'coupon_goods';
  8. protected $primaryKey = 'coupon_goods_id';
  9. protected $dateFormat = 'U';
  10. const CREATED_AT = 'coupon_goods_addtimes';
  11. const UPDATED_AT = null;
  12. public function serializeDate(DateTimeInterface $date)
  13. {
  14. return $date->format('Y-m-d H:i:s');
  15. }
  16. public function goods(){
  17. return $this->hasOne(Goods::class,'goods_id','join_coupon_goods_id');
  18. }
  19. public function skus(){
  20. return $this->hasMany(GoodsSku::class,'join_sku_goods_id','join_coupon_goods_id');
  21. }
  22. public function sku(){
  23. return $this->hasOne(GoodsSku::class,'goods_sku_id','join_coupon_goods_sku_id');
  24. }
  25. }