0

需要在审计表中添加 user_agent 的一些细节,有时需要减少 user_agent 的长度。如何配置或覆盖它。

using - owen-it/laravel-auditing

4

1 回答 1

0

覆盖类OwenIt\Auditing\Resolvers\UserAgentResolver

审计.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';
    }

}
于 2020-08-06T05:03:22.317 回答