- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 Laravel Auditing
日志中存储新数据,并在 Laravel Auditing
使用的自动日志中注册新字段。我正在尝试在 Laravel Auditing
的表中添加一个新字段,这样我就可以在审计完成后记录自定义数据。我使用的是全新的 Laravel 5.8.31
安装。
我正在将新数据添加到 audits
表的存储中。我正在修改迁移文件 2019_08_26_083436_create_audits_table.php
中的表字段以添加新的自定义字段。
Schema::create('audits', function (Blueprint $table) {
$table->increments('id');
$table->string('user_type')->nullable();
$table->unsignedBigInteger('user_id')->nullable();
$table->string('event');
$table->morphs('auditable');
$table->text('old_values')->nullable();
$table->text('new_values')->nullable();
$table->text('url')->nullable();
$table->ipAddress('ip_address')->nullable();
$table->string('user_agent')->nullable();
$table->string('tags')->nullable();
$table->timestamps();
$table->text('custom')->nullable(); <--- Like this one
$table->index(['user_id', 'user_type']);
});
我已经修改了这个解析函数,试图在新字段中存储一些东西,但它没有。
\My-project\vendor\owen-it\laravel-auditing\src\Audit.php
public function resolveData(): array
{
$morphPrefix = Config::get('audit.user.morph_prefix', 'user');
// Metadata
$this->data = [
'audit_id' => $this->id,
'audit_event' => $this->event,
'audit_url' => $this->url,
'audit_ip_address' => $this->ip_address,
'audit_user_agent' => $this->user_agent,
'audit_tags' => $this->tags,
'audit_created_at' => $this->serializeDate($this->created_at),
'audit_updated_at' => $this->serializeDate($this->updated_at),
'user_id' => $this->getAttribute($morphPrefix.'_id'),
'user_type' => $this->getAttribute($morphPrefix.'_type'),
'custom' => 'Custom Value', <--- Some new value
];
它应该在 'custom'
字段中存储 'Custom Value'
但它什么也没存储。我可能查看了错误的函数,或者这可能不是他审核新自定义数据的方式。
最佳答案
我正在使用 laravel/framework: 8.0
& owen-it/laravel-auditing: ^10.0.0
。
通过向任何实现 Auditable
的模型添加以下函数来覆盖 Auditing 的 transformAudit()
方法,以扩展 $data
数组(source)。
文件顶部:
use Illuminate\Support\Arr;
在您的模型定义中:
public function transformAudit(array $data): array
{
Arr::set($data, 'custom', 'Custom Value');
return $data;
}
作为一般规则,出于各种原因,您不想编辑 /vendor/
文件。
关于laravel - 如何在 Laravel Auditing 的表中审计新的自定义数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57755360/
我想将 Audit.EntityFramework 与 EntityFramework Core 结合使用,但仅忽略某些实体的审核日志中的插入。我在 Audit.EntityFramework 的 g
我在尝试获取引用未审计实体的审计实体时遇到问题。在我们的应用程序中,某些实体是在不使用 hibernate 的情况下引导的,这些实体是我们的元模型,不需要审计。 工作示例: public class
当我通过以下方式启用创建 session 审核时: audit create session by session; 然后我查询以下内容: select * from dba_priv_audit_o
嘿,这是我第一次使用 thepirat000 Audit.MVC 包,我已经做好了基础并且工作得很好: [Audit(EventTypeName = "InsertOrderAction", Incl
我必须将审计添加到我没有编码的系统中,并且在编程时也没有考虑审计。 然后我遇到了 Audit.Net,这是一个多么棒的框架! 我也在使用 Audit.Mvc 扩展。 无论如何,我想在 HomeCont
这是我得到的错误: npm ERR! code ENOAUDIT npm ERR! audit Your configured registry (https://registry.npmjs.org
我正在试着写一个小的Hello world程序,并用战争来包装它。我正在使用maven并编写一个SpringBoot应用程序来做这件事。。以下是我的Application.Java文件。在构建它时,我
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post一个问题。 4
首先,我对 Oracle 审计跟踪这件事还很陌生。因此,我必须审核特定用户的操作。 我的问题是,当我检查 dba_fga_audit_trail 时,我在 sql_text 列中看到用户运行了删除语句
我正在使用 nightmare 进行测试。运行 npm audit 后,我收到有关 lodash Prototype pollution 的警告。我尝试通过运行 npm audit fix 来修复
我们正在使用 Audit.NET我们的 Asp.Net Core 项目中的库来记录用户操作。最近我们决定使用Hashicorp Vault安全地存储和获取 secret ,包括 数据库凭据 . Vau
最近,由于授权/审计功能的一些奇怪行为,我的一个生产应用程序开始抛出异常。总而言之,我可以向 channel / key 组合授予权限并获得成功响应,但是当我之后立即审核 channel 时,它会显示
有没有人有一个关于如何将审计模型添加到现有项目的工作示例,用于 Audit.Net。 这是一个非常棒的组件,到目前为止,我和我的团队已经使用标准的 JSON 文件,但是,我们希望将当前的解决方案迁移到
在Hibernate中使用@Version和@Audited时,有人可以帮助我解决用例吗? 最佳答案 @Version用于与Hibernate一起实现Optimistic locking,这意味着没有
我正在尝试使用grails audit-logging插件。它似乎可以满足我的需求。 但是,在为自动生成id的域类引用id时遇到问题。 class Person { static auditable
我正在使用Grails 2.2.2,audit-trail插件2.0.3和spring-security-core 1.2.7.3 当我将注释放在类上并使用浏览器(通过Controller / gsp
我正在尝试在基于kubeadm的k8s上启用审核选项。 (v1.11.2) 但是在--audit-policy-file上添加/etc/kubernetes/manifests/kube-apiser
我将@Audited 注释用于我的基本模型。我将其扩展到我的所有实体。但它不起作用。有什么方法可以使用吗 这是我的基本模型 @MappedSuperclass @Getter @Setter @Aud
我正在使用 Audit.NET 和 EntityFramework 扩展,当我仅跟踪 1 个实体时,一切都运行良好。 现在我正在跟踪连接到第一个实体的另一个实体,当我尝试保存它时,审核保存函数会抛出反
当这个方法在 Controller 中执行时: [Route("deleteIncCloseOut")] [HttpDelete] [AuditApi] public bool deleteIncid
我是一名优秀的程序员,十分优秀!