1、laravel-activitylog
简介
- github地址
- 官方文档
- 功能:自动或手动生成日志,其中最好用的是通过设置对
Laravel model
的增删改
进行自动记录dirty attributes
- 缺点:记录中文的时候会自动
unicode
序列化,查询的时候不方便
2、改进缺点方式一
打开vendor
目录下Spatie\laravel-activitylog\src\Models\Activity.php
添加如下代码段
/**
* 如果变更的字段是`properties`,则`json_encode`的时候不要进行`Unicode`编码
* @inheritDoc
*/
public function setAttribute($key, $value)
{
// take special care for the attributes `properties`
if (in_array($key, ['properties'])) {
$this->attributes[$key] = json_encode($value, JSON_UNESCAPED_UNICODE);
return $this;
}
// apply default for everything else
return parent::setAttribute($key, $value);
}
复制代码
3、其他解决方式
暂时没找到