<?php

namespace app\model;

use DateTimeInterface;
use support\Model;

class MemberQuota extends Model
{
    protected $table = 'member_quota';

    protected $primaryKey = 'member_quota_id';

    protected $keyType = 'string';

    protected $dateFormat = 'U';

    const CREATED_AT = 'member_quota_addtimes';

    const UPDATED_AT = null;

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

    public function member()
    {
        return $this->hasOne(Member::class, 'member_id', 'join_quota_member_id');
    }

    public function cert()
    {
        return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_quota_member_id');
    }

    public function component()
    {
        return $this->hasOne(RuleAddedComponent::class, 'rule_added_component_id', 'join_member_rule_added_component_id');
    }
}