| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace common\models\forms;
- use common\models\LogAdminHandle;
- use Yii;
- class LogAdminHandleForm extends \yii\base\Model
- {
- public $_id;
- public $admin_id;
- public $admin_name;
- public $ip;
- public $created_at;
- public $request_route;
- public $opt_type;
- public $save_before_content;
- public $save_after_content;
- public $key_log;
- public $opt_obj_id;
- public $opt_obj_name;
- public $remark;
- public $user_agent;
- public $period_num;
- public $is_batch;
- public $device;
- /**
- * @inheritdoc
- */
- public function rules(){
- return [
- [['admin_id', 'admin_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'], 'trim'],
- [['admin_id', 'admin_name', 'ip', 'request_route', 'opt_type'], 'required'],
- [['created_at', 'key_log', 'is_batch', 'period_num'], 'filter', 'filter' => function($value){
- return ($value) ? $value : 0;
- }],
- [['admin_id', 'opt_obj_id'], 'string', 'max' => 32],
- [['admin_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',
- 'admin_id' => '操作人id',
- 'admin_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' => '客户端',
- ];
- }
- /**
- * 添加
- * @return LogAdminHandle|bool
- */
- public function add(){
- if(!$this->validate()){
- return false;
- }
- $model = new LogAdminHandle();
- $model->admin_id = $this->admin_id;
- $model->admin_name = $this->admin_name;
- $model->ip = $this->ip;
- $model->created_at = intval($this->created_at);
- $model->request_route = $this->request_route;
- $model->opt_type = $this->opt_type;
- $model->save_before_content = $this->save_before_content;
- $model->save_after_content = $this->save_after_content;
- $model->key_log = $this->key_log;
- $model->opt_obj_id = $this->opt_obj_id;
- $model->opt_obj_name = $this->opt_obj_name;
- $model->remark = $this->remark;
- $model->user_agent = $this->user_agent;
- $model->period_num = intval($this->period_num);
- $model->is_batch = intval($this->is_batch);
- $model->device = $this->device;
- if(!$model->save()){
- return false;
- }
- return $model;
- }
- }
|