@extends('layouts.portal') @php $first = \Illuminate\Support\Str::of($trainer->name)->before(' '); $today = $upcoming->filter(fn ($s) => $s->starts_at->isToday()); $later = $upcoming->reject(fn ($s) => $s->starts_at->isToday()); $avgs = collect($batchStats)->pluck('avg')->filter(fn ($v) => $v !== null); $hour = (int) now()->format('G'); @endphp @section('title', ($hour < 12 ? 'Good morning' : ($hour < 17 ? 'Good afternoon' : 'Good evening')).', '.$first) @section('subtitle', $today->isNotEmpty() ? 'You have '.$today->count().' class'.($today->count() === 1 ? '' : 'es').' today.' : ($pending->isNotEmpty() ? $pending->count().' register'.($pending->count() === 1 ? '' : 's').' still need attendance.' : 'Your teaching overview at a glance.')) @section('actions') Upload material Take attendance @endsection @section('content')
Active batches{{ $batches->count() }}{{ $batches->where('status', 'Running')->count() }} running now
Learners{{ $learners }}{{ $avgs->count() ? 'Average attendance '.round($avgs->avg()).'%' : 'Attendance not started' }}
Registers to complete{{ $pending->count() }}{{ $pending->isNotEmpty() ? 'Needs your action' : 'All up to date' }}
Materials uploaded{{ $materials }}Manage materials
@if($pending->isNotEmpty())

Needs action: attendance not taken

See all
@foreach($pending->take(5) as $s)
{{ $s->starts_at->format('d') }}{{ $s->starts_at->format('M') }}
{{ $s->batch->course->title }}
{{ $s->displayTitle() }} · {{ $s->starts_at->format('D g:i A') }} · {{ $s->starts_at->diffForHumans() }}
Take attendance
@endforeach
@endif

Today and coming up

Attendance
@forelse($upcoming as $s) @php $nowish = $s->starts_at->lte(now()->addMinutes(15)); @endphp
{{ $s->starts_at->format('d') }}{{ $s->starts_at->format('M') }}
{{ $s->batch->course->title }}
{{ $s->displayTitle() }}@if($s->topic) · {{ $s->topic }}@endif
{{ $s->starts_at->format('D g:i A') }} {{ $s->batch->batch_code }}{{ $s->starts_at->diffForHumans() }}
@if($s->meeting_url) Start class@endif Take attendance
@empty My batches @endforelse

My batches

@if($batches->isEmpty())
@else
@foreach($batches as $b) @php $bs = $batchStats[$b->id] ?? ['learners' => 0, 'avg' => null, 'taken' => 0, 'total' => 0]; @endphp
{{ $b->batch_code }}

{{ $b->course->title }}

{{ $bs['learners'] }} learners {{ $bs['taken'] }}/{{ $bs['total'] }} classes held
Avg attendance{{ $bs['avg'] !== null ? $bs['avg'].'%' : '—' }}
@endforeach
@endif
@endsection