@php
$headers = [
['label' => 'Action', 'class' => ''],
['label' => 'Description', 'class' => ''],
['label' => 'Admin', 'class' => 'w-36'],
['label' => 'Timestamp', 'class' => 'w-36'],
];
$rows = [];
foreach($logs as $log) {
$cells = [];
$labelClass = str_contains($log->action, 'created') ? 'bg-green-100 text-green-800' : (str_contains($log->action, 'updated') ? 'bg-blue-100 text-blue-800' : (str_contains($log->action, 'deleted') ? 'bg-red-100 text-red-800' : (str_contains($log->action, 'logged_in') ? 'bg-purple-100 text-purple-800' : 'bg-gray-100 text-gray-800')));
$cells[] = ['content' => '
' . e(str_replace('.', ' ', ucwords($log->action))) . '', 'class' => ''];
$cells[] = ['content' => '
' . e($log->description) . '
' . ($log->ip_address ? '
IP: ' . e($log->ip_address) . '
' : '') . '
', 'class' => ''];
$cells[] = ['content' => $log->admin ? '
' . e($log->admin->name) . '
' . e($log->admin->email) . '
' : '
System', 'class' => 'whitespace-nowrap'];
$cells[] = ['content' => '
' . e($log->created_at->format('M d, Y')) . '
' . e($log->created_at->format('H:i:s')) . '
', 'class' => 'whitespace-nowrap'];
$rows[] = ['cells' => $cells];
}
@endphp
@include('admin.components.table_shell', [
'headers' => $headers,
'rows' => $rows,
'emptyMessage' => 'No audit logs found',
'pagination' => $logs
])