<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "bit_admin".
 *
 * @property integer $id
 * @property string $create_date
 * @property string $modify_date
 * @property string $department
 * @property string $email
 * @property integer $is_account_enabled
 * @property integer $is_account_expired
 * @property integer $is_account_locked
 * @property integer $is_credentials_expired
 * @property string $locked_date
 * @property string $login_date
 * @property integer $login_failure_count
 * @property string $login_ip
 * @property string $name
 * @property string $password
 * @property string $username
 */
class Admin extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'bit_admin';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['create_date', 'modify_date', 'login_ip'], 'safe'],
            [['username', 'password'], 'required'],
            [['department', 'email', 'locked_date', 'login_date', 'name'], 'string'],
            [['is_account_enabled', 'is_account_expired', 'is_account_locked', 'is_credentials_expired'], 'boolean'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'create_date' => '创建日期',
            'modify_date' => '修改日期',
            'department' => '部门',
            'email' => '电子邮箱',
            'is_account_enabled' => '是否启用',
            'is_account_expired' => '是否过期',
            'is_account_locked' => '是否锁定',
            'is_credentials_expired' => '凭证过期',
            'locked_date' => '锁定日期',
            'login_date' => '登录日期',
            'login_failure_count' => '登录失败次数',
            'login_ip' => '登录IP',
            'name' => '姓名',
            'password' => '密码',
            'username' => '用户名',
            // 'description' => '描述',
        ];
    }
    
    /**
     * 加密方法
     * @param string $password
     * @return string
     */
    public static function hash($password)
    {
        return md5($password);
    }
    
}
