From e1f8caa6990dd2e5f3fff4b88a8e31e3d55060d4 Mon Sep 17 00:00:00 2001 From: afrina Date: Wed, 21 Oct 2026 14:53:30 +0800 Subject: [PATCH] fix(pembiayaan-online): remove account name fields and show customer phone on batch approval form --- .../PembiayaanOnlineService.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/Services/PembiayaanOnline/PembiayaanOnlineService.php b/app/Services/PembiayaanOnline/PembiayaanOnlineService.php index 4151106..0081c2a 100644 --- a/app/Services/PembiayaanOnline/PembiayaanOnlineService.php +++ b/app/Services/PembiayaanOnline/PembiayaanOnlineService.php @@ -694,6 +694,26 @@ class PembiayaanOnlineService ->orderBy('id', 'asc') ->get(); + // Fetch customer phone numbers in one query for the batch approval form. + $identityNumbers = $lines->pluck('nokp')->filter()->unique()->values()->all(); + $phones = []; + if ($identityNumbers) { + $customers = Customer::on('mysql7')->select('kpbaru', 'kplama', 'telefon') + ->where(function ($query) use ($identityNumbers) { + $query->whereIn('kpbaru', $identityNumbers)->orWhereIn('kplama', $identityNumbers); + })->get(); + foreach ($customers as $customer) { + foreach ([$customer->kpbaru, $customer->kplama] as $identity) { + if ($identity !== null && $identity !== '') { + $phones[(string) $identity] = $customer->telefon; + } + } + } + } + foreach ($lines as $line) { + $line->setAttribute('telefon', $phones[(string) $line->nokp] ?? null); + } + return [ 'ok' => true, 'status' => 200,