<?php
namespace app\common\model;

use think\Model;

class Admin extends Model
{
	// 设置字段信息
    protected $schema = [
        'id'          => 'int',
		'role'        => 'tinyint',
		'adminname'   => 'string',
		'password'    => 'string',
		'status'      => 'tinyint',
        'realname'    => 'string',
		'mobile'      => 'string',
        'joindate'    => 'int',
		'joinip'      => 'string',
		'lastdate'    => 'int',
		'lastip'      => 'string',
		'powerids'    => 'string',
		'remark'      => 'string'
    ];
	
	// 设置字段自动转换类型
	protected $type = [
        'joindate'    => 'timestamp:Y-m-d H:i:s',
		'lastdate'    => 'timestamp:Y-m-d H:i:s',
    ];
	
	public function getStatusTextAttr($value,$data)
	{
		$status = [1=>'正常',2=>'禁用'];
		return $status[$data['status']];
	}
	
	public function getRoleTextAttr($value,$data)
	{
		$role = [1=>'超级管理员',2=>'普通管理员'];
		return $role[$data['role']];
	}
	
	
}