Model History Tracking

Is there a recommended best practice for tracking changes to a resource/model? Meaning, tracking that User X made Change A at aa:aa:aa and then User Y made Change B at bb:bb:bb. This probably isn't a Filament-specific question but I figured someone in here might have an answer. Thanks
11 Replies
awcodes
awcodes2y ago
Check the plugins page on the Filament site. There’s 2-3 plugins for this. #logger is one I’ve used before. I’m sure there’s some more though.
bwurtz999
bwurtz999OP2y ago
thank you! missed that during my initial search
Mikazor
Mikazor2y ago
All these plugins are built on top of the https://spatie.be/docs/laravel-activitylog This package is really simple to use so it's maybe better to create your views because current plugins may not be satisfied your needs. For example #logger is not adapted for v3 (it's not using infolist view) and it's not showing an old value or changes comparison.
cheesegrits
cheesegrits2y ago
If you want a heavy duty solution that provides a full replayable audit trail, I use this for that purpose. Records every change seamlessly (you don't need to do anything), and cryptographically stamps the change logs, so you can detect any unauthorized change (one which didn't go thru your model in Laravel). https://altek.gitlab.io/accountant/
Accountant
The auditing & accountability package for Laravel's Eloquent ORM.
cheesegrits
cheesegrits2y ago
By "replayable", it means you could rebuild a given model's underlying table from an empty state, by replaying the change logs, to any point in the history. Or by unwinding the changes from the current table state to any point in the past.
bwurtz999
bwurtz999OP2y ago
@Hugh Messenger this is exactly what I was looking for! Thank you!
cheesegrits
cheesegrits2y ago
N/p. I've been using it for about a year, been very happy with it. It's kinda heavyweight, but that just comes with the territory when you need to journal every single modification to a model.
bwurtz999
bwurtz999OP2y ago
That makes sense. But like you say, to be expected given what I'm trying to accomplish
Mikazor
Mikazor2y ago
This is a good package but it works only with models. If you need to log custom actions it's not enough
Dennis Koch
Dennis Koch2y ago
Maybe my plugin based on spatie/activity-log is also an option: #pxlrbt-activity-log
cheesegrits
cheesegrits2y ago
Well yeah, but the question was about tracking changes to models, so ...

Did you find this page helpful?