Displaying 'New' and 'Old' Changes from Spatie Activity Log in an InfoList

Hello everyone! πŸ‘‹ I'm using the Spatie Activity Log package in my Laravel project to track model changes. The package logs the 'new' and 'old' values of the changed attributes in the properties field, and this data is stored as a collection. I'm facing an issue with displaying these values in a user-friendly way in my InfoList component. I want to compare the 'old' and 'new' values side by side. Here's what I have so far: - I've set up the Activity Log, and it's working fine; changes are being logged correctly. - I can access the properties field in my activity log model, which gives me a collection containing 'new' and 'old' values. properties= ({"attributes":{"title":"Pizza cheese sticks","price":4.5,"dine_in_price":0},"old":{"title":"Pizza cheese stick","price":4.5,"dine_in_price":0}}) My question is: How can I efficiently parse and display this data in an InfoList? I'm looking for a way to iterate over the 'attributes' and 'old' arrays within the properties collection and present them in a tabular or side-by-side format for easy comparison. Any suggestions or examples of how you've tackled a similar situation would be greatly appreciated! Thank you in advance!
Solution:
I found solution myself it was really simple KeyValueEntry::make('properties.attributes') ->label('New Value') ->columnSpan(2),...
Jump to solution
2 Replies
toeknee
toekneeβ€’5mo ago
With a view? Or have a look at the Awocodes activity log package and also I belive there is a new clean version that is paid for too.
Solution
Aditya Khadka | Nepal
Aditya Khadka | Nepalβ€’5mo ago
I found solution myself it was really simple KeyValueEntry::make('properties.attributes') ->label('New Value') ->columnSpan(2), KeyValueEntry::make('properties.old') ->label('Old Value') ->visible(fn (Activity $record) => $record->properties->has('old')) ->columnSpan(2),
Want results from more Discord servers?
Add your server
More Posts