<?php

namespace app\admin\model\order;

use think\Model;


class Recharge extends Model
{

    

    

    // 表名
    protected $name = 'recharge_order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
        'is_certification_text'
    ];
    

    
    public function getStatusList()
    {
        return ['created' => __('Created'), 'paid' => __('Paid'), 'expired' => __('Expired')];
    }

    public function getIsCertificationList()
    {
        return ['0' => __('Is_certification 0'), '1' => __('Is_certification 1')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsCertificationTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_certification']) ? $data['is_certification'] : '');
        $list = $this->getIsCertificationList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function user(){
        return self::hasOne("app\admin\model\User",'id',"user_id");
    }

    public function tree(){
        return self::hasOne("app\admin\model\User",'id',"user_id");
    }

    public function people(){
        return self::hasOne("app\admin\model\family\Family",'id',"user_id");
    }


}
