@php $formatAuditValue = static function ($value): string { if (is_bool($value)) { return $value ? __('messages.yes') : __('messages.no'); } if ($value === null || $value === '') { return '—'; } if (is_array($value)) { return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: '—'; } return (string) $value; }; $actionLabel = static function (?string $action): string { if (! is_string($action) || $action === '') { return '—'; } $translationKey = 'messages.audit_action_'.str_replace('.', '_', $action); $translated = __($translationKey); return $translated === $translationKey ? $action : $translated; }; @endphp

{{ __('messages.audit_logs') }}

{{ __('messages.reset') }}
@forelse ($logs as $log) @php $oldValues = is_array($log->old_values) ? $log->old_values : []; $newValues = is_array($log->new_values) ? $log->new_values : []; $changedFields = collect(array_unique(array_merge(array_keys($oldValues), array_keys($newValues)))) ->filter(fn ($field): bool => data_get($oldValues, $field) !== data_get($newValues, $field)) ->values(); $managerRoles = $log->user?->roles?->pluck('name')->values()->all() ?? []; @endphp @empty @endforelse
# {{ __('messages.manager') }} {{ __('messages.action') }} {{ __('messages.entity') }} {{ __('messages.changed_fields') }} IP {{ __('messages.created_at') }} {{ __('messages.details') }}
{{ $log->id }}

{{ $log->user?->name ?? '-' }}

{{ $log->user?->username ?? '-' }}

{{ $actionLabel($log->action) }}

{{ class_basename($log->entity_type) }} #{{ $log->entity_id ?? '-' }}

{{ $log->entity_type }}

{{ $changedFields->count() }} {{ $log->ip_address ?? '-' }} {{ $log->created_at?->format('Y-m-d H:i:s') }}
{{ __('messages.view_details') }}

{{ __('messages.manager') }}

{{ $log->user?->name ?? '-' }}

{{ __('messages.username') }}: {{ $log->user?->username ?? '-' }}

{{ __('messages.email') }}: {{ $log->user?->email ?? '-' }}

{{ __('messages.roles') }}: {{ $managerRoles !== [] ? implode(', ', $managerRoles) : '-' }}

{{ __('messages.changed_fields') }}

@if ($changedFields->isEmpty())

{{ __('messages.no_data') }}

@else
@foreach ($changedFields as $field)

{{ $field }}

{{ __('messages.old_value') }}: {{ \Illuminate\Support\Str::limit($formatAuditValue(data_get($oldValues, $field)), 120) }}

{{ __('messages.new_value') }}: {{ \Illuminate\Support\Str::limit($formatAuditValue(data_get($newValues, $field)), 120) }}

@endforeach
@endif
{{ __('messages.no_results') }}
{{ $logs->links() }}