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
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.
thank you! missed that during my initial search
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.
Introduction | laravel-activitylog
laravel-activitylog
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.
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.
@Hugh Messenger this is exactly what I was looking for! Thank you!
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.
That makes sense. But like you say, to be expected given what I'm trying to accomplish
This is a good package but it works only with models. If you need to log custom actions it's not enough
Maybe my plugin based on spatie/activity-log is also an option: #pxlrbt-activity-log
Well yeah, but the question was about tracking changes to models, so ...