Laravel审核(雄辩活动或替代) [英] Laravel Auditing (Eloquent Events or Alternatives)

查看:374
本文介绍了Laravel审核(雄辩活动或替代)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能够给我一些建议或指导。



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



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



谢谢!

解决方案

将强烈建议您查看 laravel-auditing 等内容。它为您的雄辩模型提供了丰富的审核日志,直接适用于Laravel。



说你有你的雄辩模型,那么你需要做的就是执行适当的设置说明并将 OwenIt\Auditing\AuditingTrait 添加到您要保留审核日志的模型中。




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

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).

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.

Thank you!

解决方案

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.

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

Saves significantly re-inventing the wheel.

这篇关于Laravel审核(雄辩活动或替代)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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