You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
867 B
37 lines
867 B
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
class OperateLog extends SoftDeletesModel
|
|
{
|
|
protected $hidden = ['req_parameter'];
|
|
|
|
public function admin(){
|
|
return $this->hasOne(Admin::class,'id','admin_id');
|
|
}
|
|
|
|
public function department(){
|
|
return $this->hasOne(Department::class,'id','department_id');
|
|
}
|
|
|
|
/**
|
|
* 添加记录
|
|
* @param $admin
|
|
* @param $name
|
|
* @param $remark
|
|
* @return mixed
|
|
*/
|
|
public static function addLogs($admin,$name,$remark = ''){
|
|
return self::create([
|
|
'admin_id'=>$admin->id,
|
|
'department_id'=>$admin->department_id,
|
|
'name'=>$name,
|
|
'ip'=>$_SERVER["REMOTE_ADDR"],
|
|
'url'=>request()->url(),
|
|
'req_parameter'=>json_encode(request()->all(),JSON_UNESCAPED_UNICODE),
|
|
'remark'=>$remark
|
|
]);
|
|
}
|
|
|
|
}
|