Filament Activity Logger to show old and new values
Right now I see only the new value. But I don't see the old one. Does it log only the new value that has been changed?
18 Replies
I am using this one https://filamentphp.com/plugins/z3d0x-logger
Filament
Logger by ZedoX - Filament
Extensible activity logger for filament that works out-of-the-box.
and it is not showing the old value. Only the new. I have tried updating the user's name many times but only see the newly updated name, not the original name it had before the change.
In the table column
properties
I see only this {"name": "User Changed 3rd", "updated_at": "2023-12-20 00:35:37"}
I don't see any "old"
Why is that?
It should track even the old values, right?Should. I try another activity logger? I see this one https://filamentphp.com/plugins/pxlrbt-activity-log
Filament
Activity Log by Dennis Koch - Filament
Add a Filament page that nicely shows your spatie/laravel-activitylog.
Will it work better?
According to docs it should return:
Why the json in the db doesn't have old ?
OK, so this seems to be intentional.
GitHub
Missing saved old value when update a resource · Issue #85 · Z3d0X/...
While testing the package functionalities, I noticed that the old values are missing when updating a resource. By this, I mean that in the spatie-activity log, when I update a resource, it saves th...
Anyway,
does anybody know what the author mean by this:
Hi it was an intentional choice to keep this very simple... You could disable the resource loggers and use the logging functionality provided by the base spatie-activity log? How do I "disable the resource loggers" ? What is meant by resource loggers?
You can enable and disable what you wan't to log in config file of the activity logger
How? Can you help a bit, please? In which file?
In
config/activitylog.php
?GitHub
filament-logger/config/filament-logger.php at main · Z3d0X/filament...
Extensible activity logger for filament that works out-of-the-box. - Z3d0X/filament-logger
Thanks, and what should I put there if I want old values and not only new values on updates?
I believe you can only enable and disable what is logged. Based on dev response, you should publish spatie package config file and then change things there
So, in the file
config/activitylog.php I have this:
Which code should I add to this file to log old values as well?
So, it's not done in config file?
I have to add some code in User.php model file and each other model file e.g. Product.php or Book.php?
I would like to track the old and new file like you see in Denis Koch's plugin screenshot.
@ZedoX You can see Old column and New column. Is that possible in your activity logger too?
If yes, what is the easiest way to do that? Meaning write it preferable once in some file and apply to all models/resources.
You have a few options if you want to show old & new properties
1) Replace
\Z3d0X\FilamentLogger\Loggers\ResourceLogger::class
with your own logger (you can see this file for the current implementation https://github.com/Z3d0X/filament-logger/blob/main/src/Loggers/AbstractModelLogger.php)
2) in the filament-logger.php
config file disable the https://github.com/Z3d0X/filament-logger/blob/main/config/filament-logger.php#L9. Then use configure your models for using the base spatie's activity log package https://spatie.be/docs/laravel-activitylog/v2/advanced-usage/logging-model-eventsIt seems I will try Denis Koch's plugin before starting writing a custom code as you are suggesting.
@ZedoX Do I need to uninstall/rollback your plugin before installing Denis Koch's activity logger? Or could I have both running at the same time?