From 6614e8dfba0e41bbe4f005dc15bc3bf58e39ed64 Mon Sep 17 00:00:00 2001 From: novysan87 Date: Fri, 7 Aug 2026 08:27:44 +0700 Subject: [PATCH] feat(api): sync students kini mengirim photo_url dari dokumen PAS FOTO --- .../Api/Integration/StudentSyncController.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Http/Controllers/Api/Integration/StudentSyncController.php b/app/Http/Controllers/Api/Integration/StudentSyncController.php index 40efcbd..dd10e2b 100644 --- a/app/Http/Controllers/Api/Integration/StudentSyncController.php +++ b/app/Http/Controllers/Api/Integration/StudentSyncController.php @@ -28,6 +28,7 @@ class StudentSyncController extends Controller 'department:id,code,name,description,is_active', 'classRoom:id,academic_year_id,department_id,name,level,is_active', 'parents:id,student_id,relation_type,name,nik,phone_number,is_alive', + 'documents.documentType', ]) ->orderBy('full_name') ->get([ @@ -53,6 +54,19 @@ class StudentSyncController extends Controller 'updated_at', ]) ->map(function (Student $student) { + $photoDocument = $student->documents + ->filter(function ($document) { + $code = strtoupper((string) ($document->documentType?->code ?? '')); + $name = strtolower((string) ($document->documentType?->name ?? '')); + + return $code === 'PAS_FOTO' + || $code === 'PAS FOTO' + || str_contains($name, 'pas foto') + || str_contains($name, 'pasfoto'); + }) + ->sortByDesc('created_at') + ->first(); + return [ 'id' => $student->id, 'student_number' => $student->student_number, @@ -99,6 +113,7 @@ class StudentSyncController extends Controller 'phone_number' => $student->phone_number, 'email' => $student->email, 'photo_path' => $student->photo_path, + 'photo_url' => $photoDocument?->file_path ? asset('storage/' . $photoDocument->file_path) : null, 'notes' => $student->notes, 'parents' => $student->parents ->where('is_alive', true)