<?php

namespace app\model;

use DateTimeInterface;
use support\Model;

class RuleAddedComponent extends Model
{
    protected $table = 'rule_added_component';

    protected $primaryKey = 'rule_added_component_id';

    protected $dateFormat = 'U';

    const CREATED_AT = 'rule_added_component_addtimes';

    const UPDATED_AT = null;

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

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

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