fix(tender): perbaiki pengolahan email kantor
- Mengubah cara pengolahan email dari string menjadi koleksi untuk menghindari duplikasi. - Memastikan bahwa detail email yang diambil dari JSON diproses dengan benar. - Menambahkan validasi untuk memastikan bahwa detail email adalah array sebelum diakses.
This commit is contained in:
@@ -700,15 +700,17 @@ class TenderController extends Controller
|
||||
$kjpps = KJPP::whereIn('id', $detail_penawaran)
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
$emails = [$item->email_kantor];
|
||||
$emails = collect(explode(',', $item->email_kantor))->filter()->unique();
|
||||
|
||||
// Parse JSON string jika ada dan tidak kosong
|
||||
if (!empty($item->detail_email_kantor) && $item->detail_email_kantor !== '[]') {
|
||||
$detail_emails = json_decode($item->detail_email_kantor, true);
|
||||
if (is_array($detail_emails)) {
|
||||
foreach ($detail_emails as $detail) {
|
||||
if (isset($detail['email_kantor'])) {
|
||||
$emails[] = $detail['email_kantor'];
|
||||
if (is_array($detail) && isset($detail['email_kantor'])) {
|
||||
$emails->push($detail['email_kantor']);
|
||||
} elseif (is_string($detail)) {
|
||||
$emails->push($detail);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -716,10 +718,11 @@ class TenderController extends Controller
|
||||
|
||||
return [
|
||||
'kjpp' => $item,
|
||||
'emails' => array_filter($emails)
|
||||
'emails' => array_filter($emails->unique()->values()->all())
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
foreach ($permohonan->documents as $document) {
|
||||
$village_permohonan = $document->village_code;
|
||||
$district_permohonan = $document->district_code;
|
||||
@@ -894,26 +897,30 @@ class TenderController extends Controller
|
||||
|
||||
$detail_penawaran = PenawaranDetailTender::with('kjpp')->where('kjpp_rekanan_id', '=', $id)->pluck('kjpp_rekanan_id')->toArray();
|
||||
$kjpps = KJPP::whereIn('id', $detail_penawaran)
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
$emails = [$item->email_kantor];
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
$emails = collect(explode(',', $item->email_kantor))->filter()->unique();
|
||||
|
||||
// Parse JSON string jika ada dan tidak kosong
|
||||
if (!empty($item->detail_email_kantor) && $item->detail_email_kantor !== '[]') {
|
||||
$detail_emails = json_decode($item->detail_email_kantor, true);
|
||||
if (is_array($detail_emails)) {
|
||||
foreach ($detail_emails as $detail) {
|
||||
if (isset($detail['email_kantor'])) {
|
||||
$emails[] = $detail['email_kantor'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Parse JSON string jika ada dan tidak kosong
|
||||
if (!empty($item->detail_email_kantor) && $item->detail_email_kantor !== '[]') {
|
||||
$detail_emails = json_decode($item->detail_email_kantor, true);
|
||||
if (is_array($detail_emails)) {
|
||||
foreach ($detail_emails as $detail) {
|
||||
if (is_array($detail) && isset($detail['email_kantor'])) {
|
||||
$emails->add($detail['email_kantor']);
|
||||
} elseif (is_string($detail)) {
|
||||
$emails->add($detail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_filter($emails);
|
||||
})
|
||||
->flatten()
|
||||
->toArray();
|
||||
return array_filter(array_values(iterator_to_array($emails)));
|
||||
})
|
||||
->flatten()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$dp1 = PenawaranDetailTender::with('kjpp')->where('kjpp_rekanan_id', '=', $id)->first();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user