@extends('layouts.app') @section('content') {{-- ── Page Header ── --}}

Break Sessions

Manage your break sessions within attendance records

Add
{{-- ── Active Break Card ── --}} @php $todayAttendance ??= \App\Models\Attendance::where('user_id', auth()->id()) ->whereDate('date', today()) ->first(); @endphp

Break Status

{{ now()->format('l, d M Y') }}

Session-in

{{ $activeSession ? $activeSession->session_from->format('h:i A') : '--:--' }}

Session-out

{{ $activeSession?->session_to ? $activeSession->session_to->format('h:i A') : '--:--' }}

@if ($activeSession && is_null($activeSession->session_to))

Running

{{ $activeSession->session_from->diffForHumans(short: true) }}

@endif
@if ($activeSession && is_null($activeSession->session_to))
@csrf @method('PATCH')
@elseif ($todayAttendance)
@csrf
@else
No Active Break
@endif
{{-- ── Stats Grid ── --}}
@php $statConfigs = [ [ 'label' => 'Total Sessions', 'val' => $stats['total_sessions'], 'icon' => 'icon-[tabler--list-numbers]', 'color' => 'bg-base-200 text-base-content', ], [ 'label' => 'Completed', 'val' => $stats['completed'], 'icon' => 'icon-[tabler--circle-check]', 'color' => 'bg-success/10 text-success', ], [ 'label' => 'Total Mins', 'val' => $stats['total_mins'] . 'm', 'icon' => 'icon-[tabler--clock-hour-4]', 'color' => 'bg-warning/10 text-warning', ], [ 'label' => 'Longest', 'val' => $stats['longest_mins'] . 'm', 'icon' => 'icon-[tabler--trophy]', 'color' => 'bg-secondary/10 text-secondary', ], ]; @endphp @foreach ($statConfigs as $stat)

{{ $stat['label'] }}

{{ $stat['val'] }}

@endforeach
{{-- ── Sessions Cards ── --}}
@forelse ($sessions as $session) @php $isToday = $session->attendance->date->isToday(); $isOngoing = is_null($session->session_to); // Logic for HH:MM:SS $totalSeconds = ($session->time_in_minutes ?? 0) * 60; $formattedDuration = $totalSeconds > 0 ? gmdate('H:i:s', $totalSeconds) : '--'; // Logic for colors (using minutes for the threshold) $mins = $session->time_in_minutes ?? 0; $durationColor = $mins > 60 ? 'text-error' : ($mins > 50 ? 'text-warning' : 'text-success'); @endphp
@if ($isOngoing)
ACTIVE
@elseif ($isToday)
TODAY
@endif {{-- Date + Status --}}
{{ $session->attendance->date->format('M') }} {{ $session->attendance->date->format('d') }}

{{ $session->attendance->date->format('l') }}

{{ $session->attendance->date->format('Y') }}

{{ $isOngoing ? 'Ongoing' : 'Done' }}
{{-- Session In / Out --}}

Session-in

{{ $session->session_from->format('h:i A') }}

Session-out

{{ $session->session_to ? $session->session_to->format('h:i A') : '--:--' }}
{{-- Duration Bar --}}

Duration

{{ $formattedDuration }}

Running

{{ $isOngoing ? $session->session_from->diffForHumans(short: true) : '--' }}

{{-- Actions --}}
@if ($isOngoing)
@csrf @method('PATCH')
@endif
@csrf @method('DELETE')
@empty

No sessions recorded

No break sessions found for this attendance record.

Add Session
@endforelse
{{-- Pagination --}} @if ($sessions->hasPages())
{{ $sessions->links() }}
@endif @endsection