@php $comments = $getRecord()->departmentComments->sortBy('created_at'); $initiatorId = $getRecord()->created_by_user_id; $departmentId = $getRecord()->department_id; @endphp @if ($comments->isNotEmpty())
@foreach ($comments as $comment) @php $isInitiator = $comment->user_id === $initiatorId; $isDepartmentLeader = false; if ($getRecord()->department) { $isDepartmentLeader = $getRecord()->department->isUserLeader($comment->user_id); } $bgColor = 'bg-gray-50'; // Default $alignment = 'justify-start'; // Default alignment $actionColor = 'text-gray-700'; $actionText = str_replace('_', ' ', $comment->action); if ($isInitiator) { $bgColor = 'bg-blue-50'; $alignment = 'justify-end'; $actionText = 'Responded'; $actionColor = 'text-blue-700'; } elseif ($isDepartmentLeader) { if ($comment->action === 'approved') { $bgColor = 'bg-green-50'; $actionColor = 'text-green-700'; } elseif ($comment->action === 'returned') { $bgColor = 'bg-red-50'; $actionColor = 'text-red-700'; } } @endphp

{{ $comment->user->name ?? 'System' }}

{{ $comment->created_at->format('M d, Y, H:i A') }}

Action: {{ $actionText }}

@if ($comment->comment)

{{ $comment->comment }}

@endif
@endforeach
@else

No department comments yet.

@endif