rmoore/change-recorder
Composer 安装命令:
composer require rmoore/change-recorder
包简介
records changes made to laravel models
README 文档
README
Records changes made to eloquent models (such as update/create/delete) and provides methods to check a models history
to install
composer require rmoore/change-recorder
add RMoore\ChangeRecorder\ChangeRecorderServiceProvider::class to the providers array in config\app.php
run artisan migrate to create the database table
the add the trait RMoore\ChangeRecorder\RecordsChanges to your eloquent models.
this will now automatically record changes made
to view changes we have a few choices
1st we can call $model->changes which will return a collection of Change instances containing all the data that was stored about each change
2nd we can call $model->getHistory() which will return the same results as option 1
if you wish to find specific changes, you can pass the field name as a parameter to getHistory, or you can use magic methods. please note these will only return changes where this was the only field changed at that time. if you wish to perform a more in depth search please continue reading
1st we can call get history and pass the field we want as an arguement, eg $model->getHistory('name') will return the users name history
2th we can use magic methods which take the form of get{fieldName}History(), eg $model->getNameHistory() which will return the same results as option 3
for in depth searching (aka finding changes where other fields were changed at the same time), you can use the searchHistory methods.
1st option is to pass the field as an argument, eg $model->searchHistory('name')
2nd option is to use magic methods, eg $model->searchNameHistory()
3rd option is to pass a boolean as the 2nd parameter to getHistory, eg $model->getHistory('name', true) will return the same results as options 1 and 2
rmoore/change-recorder 适用场景与选型建议
rmoore/change-recorder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 63 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 rmoore/change-recorder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rmoore/change-recorder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-18