fix(pembiayaan-online): remove account name fields and show customer phone on batch approval form
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user