@extends('partials.app') @section('content')

Training Audit Logs

@if($logs->count())
Training: {{ optional($logs->first()->subject)->name ?? 'N/A' }}
@endif @forelse($logs as $log) @empty @endforelse
User Action Changes Date
{{ $log->causer->name ?? 'System' }} {{ ucfirst($log->description) }} @php $properties = $log->properties ?? []; $attributes = data_get($properties, 'attributes', []); $old = data_get($properties, 'old', []); $new = data_get($properties, 'new', []); $extras = collect($properties)->except(['attributes', 'old', 'new']); @endphp @if(count($attributes)) @foreach($attributes as $key => $value) @php $oldValue = $old[$key] ?? null; $formattedNew = $value; $formattedOld = $oldValue; if ($key === 'is_active') { $formattedNew = $value ? 'Active' : 'Inactive'; $formattedOld = isset($oldValue) ? ($oldValue ? 'Active' : 'Inactive') : null; } if ($key === 'training_type') { $formattedNew = ucfirst(str_replace('_', ' ', $value)); $formattedOld = isset($oldValue) ? ucfirst(str_replace('_', ' ', $oldValue)) : null; } @endphp
{{ ucfirst(str_replace('_', ' ', $key)) }}: @if(!is_null($formattedOld)) {{ $formattedOld }} -> @endif {{ $formattedNew }}
@endforeach @elseif(count($new)) @foreach($new as $key => $value)
{{ ucfirst($key) }}: {{ implode(', ', (array) ($old[$key] ?? [])) }} -> {{ implode(', ', (array) $value) }}
@endforeach @elseif($extras->isNotEmpty()) @foreach($extras as $key => $value)
{{ ucfirst(str_replace('_', ' ', $key)) }}: {{ is_array($value) ? implode(', ', $value) : $value }}
@endforeach @else No visible changes @endif
{{ $log->created_at->format('d M Y, h:i A') }}
No audit logs found.
@endsection