@php // So we get both a $record and $children passed, we need to fetch audits for all $audits = $record->audits()->orderBy('created_at', 'desc')->get(); foreach ($children as $child) { $record->{$child}()->each(function ($childRecord) use (&$audits) { $audits = $audits->merge($childRecord->audits()->orderBy('created_at', 'desc')->get()); }); } $audits = $audits->sortByDesc('created_at')->sortByDesc('id'); @endphp
@foreach ($audits as $audit)
{{ $audit->user?->name ?? 'System' }} @if($audit->event == 'extension_action' && isset($audit->new_values['action'])) {{ str_replace('_', ' ', $audit->new_values['action']) }} @else {{ $audit->event }} @endif {{ class_basename($audit->auditable_type) }} (#{{ $audit->auditable_id }})
@if($audit->tags && $audit->tags == 'admin') @endif {{ $audit->created_at->format('Y-m-d H:i:s') }}
@if($audit->event == 'created')
@if(count($audit->getModified()) === 0) No changes @else @foreach ($audit->getModified() as $key => $value) @if(empty($value['new'])) @continue @endif
{{ $key }}

{{ $value['new'] ?? '' }}

@endforeach @endif
@elseif($audit->event !== 'extension_action')
@if(count($audit->getModified()) === 0) No changes @else @foreach ($audit->getModified() as $key => $value)
{{ $key }} changed from

{{ $value['old'] ?? '' }}

->

{{ $value['new'] ?? '' }}

@endforeach @endif
@endif
@endforeach