diff --git a/app/Jobs/ProcessArrangementDataJob.php b/app/Jobs/ProcessArrangementDataJob.php index cb03da7..0fde821 100644 --- a/app/Jobs/ProcessArrangementDataJob.php +++ b/app/Jobs/ProcessArrangementDataJob.php @@ -29,7 +29,7 @@ public function handle() : void { - $filePath = storage_path('app/20240901.ST.AA.ARRANGEMENT.csv'); // Adjust this path as needed + $filePath = storage_path('app/20250207.ST.AA.ARRANGEMENT.csv'); // Adjust this path as needed try { if (!file_exists($filePath)) { throw new Exception("File not found: $filePath"); @@ -37,23 +37,20 @@ set_time_limit(24 * 60 * 60); - if (!file_exists($filePath)) { - throw new Exception("File not found: {$filePath}"); - } - $handle = fopen($filePath, "r"); if ($handle !== false) { $headers = (new TempArrangement())->getFillable(); - while (($row = fgetcsv($handle, 0, ";")) !== false) { - unset($row[0]); // Remove the first empty column if present + while (($row = fgetcsv($handle, 0, "~")) !== false) { if (count($headers) === count($row)) { $data = array_combine($headers, $row); - TempArrangement::updateOrCreate( - ['arrangement_id' => $data['arrangement_id']], // key to find existing record - $data // data to update or create - ); + if($data['arrangement_id']!== 'arrangement_id') { + TempArrangement::updateOrCreate( + ['arrangement_id' => $data['arrangement_id']], // key to find existing record + $data // data to update or create + ); + } } } fclose($handle);