From c3bda9c0cf552cc9ac301d5dc557cf8a0236b353 Mon Sep 17 00:00:00 2001 From: Novy San87 Date: Thu, 6 Aug 2026 20:15:31 +0700 Subject: [PATCH] feat: summary kehadiran berbasis hari (1 hari = 1 status utama) --- .../Controllers/Api/ParentStudentController.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/ParentStudentController.php b/app/Http/Controllers/Api/ParentStudentController.php index b24850d..e9a31d7 100644 --- a/app/Http/Controllers/Api/ParentStudentController.php +++ b/app/Http/Controllers/Api/ParentStudentController.php @@ -199,11 +199,19 @@ class ParentStudentController extends Controller ->sortByDesc('date') ->values(); - $summary = []; - foreach ($statuses as $s) { - $summary[$s] = $rows->where('status', $s)->count(); + // Ringkasan berbasis HARI (bukan jam pelajaran): + // 1 hari = 1 status utama (urutan prioritas hadir > izin > sakit > alpha). + $summary = ['hadir' => 0, 'izin' => 0, 'sakit' => 0, 'alpha' => 0]; + foreach ($byDate as $items) { + foreach ($statuses as $s) { + if ($items->where('status', $s)->count() > 0) { + $summary[$s]++; + break; + } + } } $summary['days'] = $byDate->count(); + $summary['based_on'] = 'days'; return response()->json([ 'from' => $from,