<?php

namespace app\common\model;

class AdminModel extends BaseModel
{
    // 设置表名
    protected $name = 'admin';

    //自动完成
    protected $autoWriteTimestamp = true;

    // 设置字段自动转换类型
    protected $type = [
        'join_date' => 'timestamp:Y-m-d H:i:s',
        'last_date' => 'timestamp:Y-m-d H:i:s',
    ];

    // 常量
    const STATUS = [1 => '正常', 2 => '禁用'];
    const ROLE   = [1 => '超级管理员', 2 => '普通管理员'];

    const STATUS_NORMAL  = 1;
    const STATUS_DISABLE = 2;
    const ROLE_SUPER     = 1;
    const ROLE_NORMAL    = 2;

    public function getStatusTextAttr($value, $data)
    {
        return self::STATUS[$data['status']];
    }

    public function getRoleTextAttr($value, $data)
    {
        return self::ROLE[$data['role']];
    }


}