fix(pembiayaan-online): remove account name fields and show customer phone on batch approval form

This commit is contained in:
2026-10-21 14:53:30 +08:00
parent aac29bc199
commit e1f8caa699
@@ -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,