Laravel 审计(Eloquent Events 或 Alternatives) [英] Laravel Auditing (Eloquent Events or Alternatives)

查看:14
本文介绍了Laravel 审计(Eloquent Events 或 Alternatives)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能给我一些建议或方向.

I am hoping that someone would be able to give me some advice or direction.

我有多个表,这些表有 created_by 和 updated_by 列.我使用这些字段来确定谁创建了记录以及谁最后修改了它.(只是一种快速简单的方法来审核更改).

I have multiple tables, these tables have created_by and updated_by columns. I use these fields to determine who created the record and also who modified it last. ( Just a quick and simple method to audit changes).

如果可以,我有两个问题:1. 这是进行审计(跟踪创建者/修改者)的好方法吗?2. 更新这些字段的最佳方法是什么.我是使用 Eloquent 事件还是有更好的选择?任何指针都会很棒.

I have 2 questions if I may: 1. Is this a good way to do auditing (keeping track of the creator / modifier)? 2. What is the best way to update these fields. Do I make use of Eloquent events or is there a better alternative? Any pointers would be awesome.

谢谢!

推荐答案

我强烈建议查看类似 laravel 审计.它为您的雄辩模型提供了丰富的审计日志,并直接适用于 Laravel.

I would strongly suggest checking out something like laravel-auditing. It gives a rich auditing log for your eloquent models and fits straight into Laravel.

假设你有你的 Eloquent 模型,那么你需要做的就是执行适当的设置说明并将 OwenItAuditingAuditingTrait 添加到你想要保留审计日志的模型中.

Say you have your Eloquent model then all you need to do is carry out the appropriate setup instructions and add the OwenItAuditingAuditingTrait to your models that you want to keep an audit log for.

大大节省了重新发明轮子的时间.

Saves significantly re-inventing the wheel.

这篇关于Laravel 审计(Eloquent Events 或 Alternatives)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆