如何添加 prefix/suffix 或修改 Audit - laravel 的 user_agent 值?
How to add prefix/suffix or modify user_agent value of Audit - laravel?
需要在审计table中用user_agent添加一些细节,有时需要减少user_agent的长度。如何配置或覆盖它。
using - owen-it/laravel-auditing
覆盖 class OwenIt\Auditing\Resolvers\UserAgentResolver
,
audit.php
'resolver' => [
...
'user_agent' => App\Resolvers\UserAgentResolver::class,
...
],
App\Resolvers\UserAgentResolver.php
class UserAgentResolver implements \OwenIt\Auditing\Contracts\UserAgentResolver
{
/**
* {@inheritdoc}
*/
public static function resolve()
{
return 'Prefix-'.substr(
Request::header('User-Agent'), 0, 50
).'-Suffix';
}
}
需要在审计table中用user_agent添加一些细节,有时需要减少user_agent的长度。如何配置或覆盖它。
using - owen-it/laravel-auditing
覆盖 class OwenIt\Auditing\Resolvers\UserAgentResolver
,
audit.php
'resolver' => [
...
'user_agent' => App\Resolvers\UserAgentResolver::class,
...
],
App\Resolvers\UserAgentResolver.php
class UserAgentResolver implements \OwenIt\Auditing\Contracts\UserAgentResolver
{
/**
* {@inheritdoc}
*/
public static function resolve()
{
return 'Prefix-'.substr(
Request::header('User-Agent'), 0, 50
).'-Suffix';
}
}