CouponGoods.php 832 B

12345678910111213141516171819202122232425262728293031323334353637
  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. ->where('goods_sku_status','ON');
  22. }
  23. public function sku(){
  24. return $this->hasOne(GoodsSku::class,'goods_sku_id','join_coupon_goods_sku_id');
  25. }
  26. }