<?php

namespace app\model;

use DateTimeInterface;
use support\Model;

class CouponGoods extends Model
{
    protected $table = 'coupon_goods';

    protected $primaryKey = 'coupon_goods_id';

    protected $dateFormat = 'U';

    const CREATED_AT = 'coupon_goods_addtimes';

    const UPDATED_AT = null;

    public function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function goods(){
        return $this->hasOne(Goods::class,'goods_id','join_coupon_goods_id');
    }

    public function skus(){
        return $this->hasMany(GoodsSku::class,'join_sku_goods_id','join_coupon_goods_id')
            ->where('goods_sku_status','ON');
    }

    public function sku(){
        return $this->hasOne(GoodsSku::class,'goods_sku_id','join_coupon_goods_sku_id');
    }
}