From 225ec85bad83481b6a1cdaf4f98fe7e0181a318f Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Wed, 9 Apr 2025 13:50:56 +0700 Subject: [PATCH] feat(job): perbarui jalur file dan pemisah CSV pada ProcessStmtNarrFormatDataJob - Memperbarui pemisah CSV dari ';' menjadi '~'. - Menambahkan pengecekan untuk memastikan '_id' tidak sama dengan 'id' sebelum melakukan update atau create. --- app/Jobs/ProcessStmtNarrFormatDataJob.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Jobs/ProcessStmtNarrFormatDataJob.php b/app/Jobs/ProcessStmtNarrFormatDataJob.php index b8885a3..00a0816 100644 --- a/app/Jobs/ProcessStmtNarrFormatDataJob.php +++ b/app/Jobs/ProcessStmtNarrFormatDataJob.php @@ -29,7 +29,7 @@ public function handle() : void { - $filePath = storage_path('app/20240901.ST.STMT.NARR.FORMAT.csv'); // Adjust this path as needed + $filePath = storage_path('app/20250207.ST.STMT.NARR.FORMAT.csv'); // Adjust this path as needed try { if (!file_exists($filePath)) { throw new Exception("File not found: $filePath"); @@ -45,11 +45,13 @@ if ($handle !== false) { $headers = (new TempStmtNarrFormat())->getFillable(); - while (($row = fgetcsv($handle, 0, ";")) !== false) { + while (($row = fgetcsv($handle, 0, "~")) !== false) { if (count($headers) === count($row)) { $data = array_combine($headers, $row); try { - TempStmtNarrFormat::updateOrCreate(['_id' => $data['_id']], $data); + if($data['_id'] !== 'id') { + TempStmtNarrFormat::updateOrCreate(['_id' => $data['_id']], $data); + } } catch (Exception $e) { Log::error('Error processing stmt narr format: ' . $e->getMessage()); }