<?php

namespace app\model;

use DateTimeInterface;
use support\Model;

class PayDetail extends Model
{
    protected $table = 'pay_detail';

    protected $dateFormat = 'U';

    protected $primaryKey = 'pay_id';

    const CREATED_AT = 'pay_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_pay_member_id')
            ->select('member_id', 'member_mobile');
    }

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

    public function memberAccount()
    {
        return $this->hasMany(MemberAccount::class, 'join_account_member_id', 'join_pay_member_id')
            ->select('join_account_member_id','member_account_surplus','member_account_added','member_account_classify','member_account_name');
    }
}