@php
$allNotifications = collect();
// Add documents
foreach($documents as $doc) {
$allNotifications->push([
'type' => 'document',
'icon' => 'fas fa-file-alt text-info fa-2x',
'title' => 'New Document',
'description' => $doc->description,
'time' => $doc->updated_at,
'url' => route('documents.index'),
'action_text' => 'View Document'
]);
}
// Add holiday responses
foreach($holidayResponses as $holiday) {
$status = $holiday->status;
$color = $status == 'Approved' ? 'success' : ($status == 'Rejected' ? 'danger' : 'warning');
$allNotifications->push([
'type' => 'holiday_response',
'icon' => 'fas fa-plane-departure text-' . $color . ' fa-2x',
'title' => 'Holiday Request ' . $status,
'description' => date('d M Y', strtotime($holiday->start_date)) . ' - ' . date('d M Y', strtotime($holiday->end_date)) . ' (' . number_format($holiday->number_days, 1) . ' days)',
'time' => $holiday->updated_at,
'url' => route('holidays.viewing'),
'action_text' => 'View Request'
]);
}
// Add approval requests
foreach($approvalRequests as $request) {
$allNotifications->push([
'type' => 'approval_request',
'icon' => 'fas fa-thumbs-up text-warning fa-2x',
'title' => 'Approval Needed',
'description' => $request->name . ' requested ' . number_format($request->number_days, 1) . ' days (' . date('d M', strtotime($request->start_date)) . ' - ' . date('d M', strtotime($request->end_date)) . ')',
'time' => $request->updated_at,
'url' => route('holiday_approval.index'),
'action_text' => 'Review'
]);
}
$allNotifications = $allNotifications->sortByDesc('time');
@endphp
@if($allNotifications->count() > 0)
@foreach($allNotifications as $notification)
-
{{ $notification['title'] }}
{{ $notification['description'] }}
{{ $notification['time']->diffForHumans() }}
@endforeach
@else
@endif