<?php

namespace common\models;

use common\components\MongoActiveRecord;
use Yii;

/**
 * This is the model class for collection "ar_bonus_admin_login".
 *
 * @property \MongoDB\BSON\ObjectID|string $_id
 * @property mixed $adm_name
 * @property mixed $opt_type
 * @property mixed $return_result
 * @property mixed $success_times
 * @property mixed $fail_times
 * @property mixed $device
 * @property mixed $request_route
 * @property mixed $ip
 * @property mixed $created_at
 * @property mixed $user_agent
 * @property mixed $period_num
 */
class LogAdminLogin extends MongoActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function collectionName()
    {
        return 'ar_bonus_admin_login';
    }

    /**
     * @return \yii\mongodb\Connection the MongoDB connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('dbLog');
    }

    /**
     * 获取id
     * @return string
     */
    public function getId() {
        return (string) $this->_id;
    }
    /**
     * {@inheritdoc}
     */
    public function attributes()
    {
        return [
            '_id',
            'adm_name',
            'ip',
            'created_at',
            'user_agent',
            'period_num',
            'opt_type',
            'success_times',
            'fail_times',
            'device',
            'request_route',
            'return_result',
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['adm_name', 'ip', 'request_route'], 'required'],
            [['created_at', 'success_times', 'period_num', 'fail_times'], 'integer'],
            [['adm_name', 'ip',  'opt_type'], 'string', 'max' => 16],
            [['_id', 'return_result', 'device',], 'safe'],
            [['user_agent', 'request_route'], 'string', 'max' => 1000],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            '_id' => 'ID',
            'adm_name' => '对象编号',
            'ip' => '操作ip',
            'created_at' => '创建时间',
            'user_agent' => '浏览器特征',
            'period_num' => '期数',
            'opt_type' => '操作类型',
            'success_times' => '登陆成功次数',
            'fail_times' => '登录失败次数',
            'device' => '客户端',
            'request_route' => '请求路径',
            'return_result' => '返回内容',
        ];
    }

}
