diff --git a/readme.md b/readme.md index 0101fbc..4acec0b 100644 --- a/readme.md +++ b/readme.md @@ -22,11 +22,10 @@ composer require pxlrbt/filament-activity-log ``` > **Note** -> This plugin only offers a page to show activities related to your model. You need [`spatie/laravel-activitylog`](https://github.com/spatie/laravel-activitylog) installed and configured for it to work. +> This plugin only offers a page to show activities related to your model. You need [`spatie/laravel-activitylog`](https://github.com/spatie/laravel-activitylog) installed and configured for it to work. It is important you are using the `LogsActivity` trait as per [Spatie's docs](https://spatie.be/docs/laravel-activitylog/v4/advanced-usage/logging-model-events) for this work as we use the '->activities()' method of the trait. ## Usage - Make sure you use a **custom theme** and the vendor folder for this plugins is published, so that it includes the Tailwind CSS classes. ### Create a page diff --git a/resources/views/pages/list-activities.blade.php b/resources/views/pages/list-activities.blade.php index dd02306..22d6fc6 100644 --- a/resources/views/pages/list-activities.blade.php +++ b/resources/views/pages/list-activities.blade.php @@ -39,15 +39,27 @@ $changes = $activityItem->getChangesAttribute(); @endphp @foreach(data_get($changes, 'attributes', []) as $field => $change) + @php + $oldValue = data_get($changes, "old.{$field}"); + $newValue = data_get($changes, "attributes.{$field}"); + @endphp $loop->even])> {{ $this->getFieldLabel($field) }} - {{ data_get($changes, "old.{$field}") }} + @if(is_array($oldValue)) +
{{ json_encode($oldValue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) }}
+ @else + {{ $oldValue }} + @endif
- {{ data_get($changes, "attributes.{$field}") }} + @if(is_array($newValue)) +
{{ json_encode($newValue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) }}
+ @else + {{ $newValue }} + @endif
@endforeach