UserAuditA.php 1.6 KB
<?php

namespace app\admin\model;

use think\Model;


class UserAuditA extends Model
{

    

    

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

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

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

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

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

    public function getIsStuList()
    {
        return ['0' => __('Is_stu 0'), '1' => __('Is_stu 1'), '2' => __('Is_stu 2')];
    }


    public function getSexDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sex_data']) ? $data['sex_data'] : '');
        $list = $this->getSexDataList();
        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 getIsStuTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_stu']) ? $data['is_stu'] : '');
        $list = $this->getIsStuList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}