<?php

namespace common\models;

use common\components\MongoActiveRecord;
use Yii;

/**
 * This is the model class for collection "ar_shop_admin_log".
 *
 * @property \MongoDB\BSON\ObjectID|string $_id
 * @property mixed $user_id
 * @property mixed $user_name
 * @property mixed $ip
 * @property mixed $created_at
 * @property mixed $request_route
 * @property mixed $opt_type
 * @property mixed $save_before_content
 * @property mixed $save_after_content
 * @property mixed $key_log
 * @property mixed $opt_obj_id
 * @property mixed $opt_obj_name
 * @property mixed $remark
 * @property mixed $user_agent
 * @property mixed $period_num
 * @property mixed $is_batch
 * @property mixed $device
 */
class LogUserHandle extends MongoActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function collectionName()
    {
        return 'ar_bonus_user_log';
    }

    /**
     * @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',
            'user_id',
            'user_name',
            'ip',
            'created_at',
            'request_route',
            'opt_type',
            'save_before_content',
            'save_after_content',
            'key_log',
            'opt_obj_id',
            'opt_obj_name',
            'remark',
            'user_agent',
            'period_num',
            'is_batch',
            'device',
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['user_id', 'user_name', 'ip', 'request_route', 'opt_type'], 'required'],
            [['created_at', 'key_log', 'period_num', 'is_batch'], 'integer'],
            [['user_id', 'opt_obj_id'], 'string', 'max' => 32],
            [['user_name', 'ip', 'opt_obj_name'], 'string', 'max' => 16],
            [['_id', 'opt_type', 'save_before_content', 'save_after_content', 'device'], 'safe'],
            [['user_agent', 'request_route', 'remark'], 'string', 'max' => 1000],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            '_id' => 'ID',
            'user_id' => '操作人id',
            'user_name' => '操作人',
            'ip' => '操作ip',
            'created_at' => '创建时间',
            'request_route' => '请求路由',
            'opt_type' => '操作类型',
            'save_before_content' => '保存前的内容',
            'save_after_content' => '保存后的内容',
            'key_log' => '关键日志',
            'opt_obj_id' => '操作对象id',
            'opt_obj_name' => '操作对象名称',
            'remark' => '备注',
            'user_agent' => '浏览器特征',
            'period_num' => '期数',
            'is_batch' => '批量保存',
            'device' => '客户端',
        ];
    }

}
