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