{{-- My Courses — full enrolled-course listing. From EmployeeCourseController@index: $courses = Collection each with ->pivot->status (live) and ->pivot->progress_percent $stats = ['total','completed','in_progress','overdue'] --}} @extends('layouts.app') @section('title', 'My Courses') @section('content') @include('employee._flash') {{-- Summary tiles --}}
@php $tiles = [ ['label' => 'Assigned', 'value' => $stats['total'], 'icon' => 'school', 'class' => 'text-primary'], ['label' => 'Completed', 'value' => $stats['completed'], 'icon' => 'task_alt', 'class' => 'text-on-secondary-container'], ['label' => 'In Progress', 'value' => $stats['in_progress'], 'icon' => 'timelapse', 'class' => 'text-secondary'], ['label' => 'Overdue', 'value' => $stats['overdue'], 'icon' => 'warning', 'class' => 'text-error'], ]; @endphp @foreach($tiles as $tile)
{{ $tile['icon'] }}

{{ $tile['value'] }}

{{ $tile['label'] }}

@endforeach
{{-- Filter tabs --}}
@php $filters = [ 'all' => 'All', 'mandatory' => 'Mandatory', 'service_specific' => 'Service Specific', 'in_progress' => 'In Progress', 'overdue' => 'Overdue', 'completed' => 'Completed', 'not_started' => 'Not Started', ]; @endphp @foreach($filters as $key => $label) @if($key === 'service_specific') @endif @endforeach
{{-- Course grid --}} @if($courses->isEmpty())
school

No courses assigned yet

When your manager assigns training, it'll appear here.

@else
@foreach($courses as $course) @php $status = $course->pivot->status ?? 'not_started'; $progress = $course->pivot->progress_percent ?? 0; $badge = match($status) { 'completed' => ['label' => 'Completed', 'class' => 'bg-secondary-container text-on-secondary-container'], 'overdue' => ['label' => 'Overdue', 'class' => 'bg-error-container text-error'], 'in_progress' => ['label' => $progress . '% done', 'class' => 'bg-primary/10 text-primary'], default => ['label' => 'Not started', 'class' => 'bg-surface-container-high text-on-surface-variant'], }; // Due-date line: hidden once completed; colour by urgency otherwise. $due = $course->pivot->due_at ? \Illuminate\Support\Carbon::parse($course->pivot->due_at) : null; $daysLeft = $due ? (int) ceil(now()->startOfDay()->diffInDays($due->copy()->startOfDay(), false)) : null; if ($status === 'completed' || ! $due) { $dueMeta = null; } elseif ($daysLeft < 0) { $dueMeta = ['icon' => 'event_busy', 'class' => 'text-error', 'label' => 'Overdue · ' . abs($daysLeft) . 'd ago']; } elseif ($daysLeft === 0) { $dueMeta = ['icon' => 'schedule', 'class' => 'text-error', 'label' => 'Due today']; } elseif ($daysLeft <= 7) { $dueMeta = ['icon' => 'schedule', 'class' => 'text-error', 'label' => 'Due in ' . $daysLeft . 'd · ' . $due->format('j M Y')]; } elseif ($daysLeft <= 30) { $dueMeta = ['icon' => 'event', 'class' => 'text-secondary', 'label' => 'Due ' . $due->format('j M Y')]; } else { $dueMeta = ['icon' => 'event', 'class' => 'text-outline', 'label' => 'Due ' . $due->format('j M Y')]; } @endphp
@if($course->thumbnail) {{ $course->title }} @else
school
@endif
{{ $course->duration_minutes }} min
@if($course->requires_external_cert)

open_in_new External website · upload certificate

@elseif($course->category === 'service_specific')

Service Specific

@else

Mandatory

@endif

{{ $course->title }}

{{ $badge['label'] }} @if($dueMeta) {{ $dueMeta['icon'] }}{{ $dueMeta['label'] }} @elseif($status === 'completed') task_altDone @endif
@endforeach
@endif {{-- Sessions (face-to-face trainings) this person is booked onto — DataTable --}} @isset($sessions) @if($sessions->isNotEmpty()) @php $sessRole = auth()->user()->primaryRole(); $sessLink = function ($s) use ($sessRole) { if (\Illuminate\Support\Facades\Route::has($sessRole.'.session.show')) return route($sessRole.'.session.show', $s); if (\Illuminate\Support\Facades\Route::has($sessRole.'.sessions.show')) return route($sessRole.'.sessions.show', $s); return null; }; @endphp
event

Sessions (Face to Face Trainings)

{{ $sessions->count() }}
@foreach($sessions as $r) @php $s = $r['session']; $badge = match($r['status']) { 'attended' => ['Attended', 'bg-primary/10 text-primary'], 'no_show' => ['Missed', 'bg-error-container text-error'], default => $r['upcoming'] ? ['Upcoming', 'bg-secondary-container text-on-secondary-container'] : ['Booked', 'bg-surface-container-high text-on-surface-variant'], }; $venue = $s->format === 'online' ? 'Online' : ($s->location ?: 'Venue TBC'); $link = $sessLink($s); @endphp @endforeach
Date Training Time Venue Trainer Status
{{ $s->session_date->format('j M Y') }} @if($link) {{ $s->title }} @else {{ $s->title }} @endif {{ \Carbon\Carbon::parse($s->start_time)->format('H:i') }} {{ $s->format === 'online' ? 'videocam' : 'location_on' }}{{ $venue }} {{ $s->trainerName() ?? '—' }} {{ $badge[0] }}
@endif @endisset @endsection