update nama cawangan dalam carian nama arcc

This commit is contained in:
Nur Izzati
2025-08-04 12:52:01 +08:00
parent ede5280151
commit cb572f728d
2 changed files with 20 additions and 5 deletions
+18 -3
View File
@@ -391,11 +391,26 @@ class CallCenterController extends Controller
$customers = $response->json();
// Jika lebih dari satu pelanggan dijumpai
if (is_array($customers) && count($customers) > 1) {
Session::put('customer_list', $customers);
return redirect()->route('arcc.pilihpelanggan');
if (is_array($customers) && count($customers) > 1) {
// Tambah nama cawangan untuk setiap pelanggan
foreach ($customers as &$customer) {
$kodcaw = $customer['kodcaw'] ?? null;
if ($kodcaw) {
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/cawangan/' . $kodcaw)
->json();
$customer['nama_cawangan'] = $cawangan['details_caw'] ?? $kodcaw;
} else {
$customer['nama_cawangan'] = '-';
}
}
Session::put('customer_list', $customers);
return redirect()->route('arcc.pilihpelanggan');
}
// Jika satu pelanggan dijumpai
$customer_info = $customers[0] ?? null;
} else {