<?php

namespace app\admin\model;

use think\Model;


class Doctor extends Model
{

    

    

    // 表名
    protected $table = 'doctor';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

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

    // 追加属性
    protected $append = [
        'ruletype_text',
        'gender_text',
        'idcard_status_text',
        'doctor_status_text',
        'english_status_text',
        'status_text'
    ];
    

    
    public function getRuletypeList()
    {
        return ['1' => __('Ruletype 1'), '2' => __('Ruletype 2')];
    }

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

    public function getIdcardStatusList()
    {
        return ['-1' => __('Idcard_status -1'), '0' => __('Idcard_status 0'), '1' => __('Idcard_status 1'), '2' => __('Idcard_status 2')];
    }

    public function getDoctorStatusList()
    {
        return ['-1' => __('Doctor_status -1'), '0' => __('Doctor_status 0'), '1' => __('Doctor_status 1'), '2' => __('Doctor_status 2')];
    }

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

    public function getStatusList()
    {
        return ['1' => __('Status 1'), '0' => __('Status 0'), '-1' => __('Status -1')];
    }


    public function getRuletypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['ruletype']) ? $data['ruletype'] : '');
        $list = $this->getRuletypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGenderTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
        $list = $this->getGenderList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIdcardStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['idcard_status']) ? $data['idcard_status'] : '');
        $list = $this->getIdcardStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDoctorStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['doctor_status']) ? $data['doctor_status'] : '');
        $list = $this->getDoctorStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getEnglishStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['english_status']) ? $data['english_status'] : '');
        $list = $this->getEnglishStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


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




    public function keshi()
    {
        return $this->belongsTo('Keshi', 'keshi_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function doctorlevel()
    {
        return $this->belongsTo('doctorlevel', 'level_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function wallet()
    {
        return $this->belongsTo('Doctorwallet', 'id', 'doctor_id', [], 'LEFT')->setEagerlyType(0);
    }
}
