I use this package and thanks for this useful package.
I want show all change on my blade file.
Is it true?
@foreach($activityLog->changes['attributes'] as $key=>$val)
{{"field $key " .$activityLog->changes['old'][$key]." change to ".$activityLog->changes['attributes'][$key]}}<br>
@endforeach
This looks alright. Did you try this? Did it work?
Yes it works, But I want to know is this the right thing to do?
hmm, does not look nice
@leep0o What's your suggestion?
@leep0o The code above simply pulls in the data. The styling would be completely up to you and would be pretty individual based on the existing styling within the app.
By using translation strings you could make the code a bit cleaner and prepare for multi-language support.
lang/en/activitylog.php
return [
'field_change' => 'field :field changed from :old_value to :new_value.',
];
@foreach($activityLog->changes['attributes'] as $field => $value)
{{ trans('activitylog.field_change', ['field' => $field, 'old_value' => $activityLog->changes['old'][$field], 'new_value' => $activityLog->changes['attributes'][$key]]) }}
@endforeach
In general I recommend using a table, primary with a plugin like list.js, dataTable or whatever, to allow the user to sort, search and see everything in clean columns and not floating texts.
<table>
<thead>
<tr>
<th>field</th>
<th>old</th>
<th>new</th>
</thead>
<tbody>
@foreach($activities as $activityLog)
@foreach($activityLog->changes['attributes'] as $field => $value)
<tr>
<td>{{ $field }}</td>
<td>{{ $activityLog->changes['old'][$field] }}</td>
<td>{{ $activityLog->changes['attributes'][$key] }}</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
Thanks for answering @Gummibeer
Hello, let me know how to change text format for spatie activity log . Now showing the following line.
{"old":{"name":"test"},"attributes":{"name":"test testing"}}
Please help .
Most helpful comment
By using translation strings you could make the code a bit cleaner and prepare for multi-language support.
lang/en/activitylog.php
In general I recommend using a table, primary with a plugin like list.js, dataTable or whatever, to allow the user to sort, search and see everything in clean columns and not floating texts.