<?php

namespace common\models;

use common\components\MongoActiveRecord;
use Yii;

/**
 * This is the model class for collection "ar_bonus_system_log".
 *
 * @property \MongoDB\BSON\ObjectID|string $_id
 * @property mixed $ip
 * @property mixed $created_at
 * @property mixed $request_route
 * @property mixed $opt_type
 * @property mixed $request_content
 * @property mixed $response_content
 * @property mixed $opt_obj_id
 * @property mixed $opt_obj_name
 * @property mixed $opt_target_name
 * @property mixed $opt_user
 * @property mixed $user_agent
 * @property mixed $period_num
 * @property mixed $is_batch
 * @property mixed $device
 */
class LogSystem extends MongoActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function collectionName()
    {
        return 'ar_bonus_system_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',
            'ip',
            'created_at',
            'request_route',
            'opt_type',
            'request_content',
            'response_content',
            'opt_obj_id',
            'opt_obj_name',
            'opt_target_name',
            'opt_user',
            'user_agent',
            'period_num',
            'is_batch',
            'device',
        ];
    }

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

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            '_id' => 'ID',
            'ip'=>'操作ip',
            'created_at'=>'创建时间',
            'request_route'=>'请求路由',
            'opt_type'=>'操作类型',
            'request_content'=>'请求内容',
            'response_content'=>'响应内容',
            'opt_obj_id'=>'操作对象id',
            'opt_obj_name'=>'操作对象名称',
            'opt_target_name'=>'操作对象',
            'opt_user'=>'操作人',
            'user_agent'=>'浏览器特征',
            'period_num'=>'期数',
            'is_batch'=>'批量保存',
            'device'=>'客户端',
        ];
    }

}
