diff --git a/app/Jobs/ProcessStmtEntryDataJob.php b/app/Jobs/ProcessStmtEntryDataJob.php new file mode 100644 index 0000000..b29dd28 --- /dev/null +++ b/app/Jobs/ProcessStmtEntryDataJob.php @@ -0,0 +1,68 @@ +getFillable(); + while (($row = fgetcsv($handle, 0, "/")) !== false) { + if (count($headers) === count($row)) { + $data = array_combine($headers, $row); + + try { + TempStmtEntry::updateOrCreate(['_id' => $data['_id']], $data); + } catch (Exception $e) { + Log::error('Error processing stmt entry: ' . $e->getMessage()); + } + } + } + fclose($handle); + } else { + throw new Exception("Unable to open file: {$filePath}"); + } + } catch (Exception $e) { + Log::error('Error in ProcessStmtEntryDataJob: ' . $e->getMessage()); + throw $e; + } + } + } diff --git a/app/Models/TempStmtEntry.php b/app/Models/TempStmtEntry.php new file mode 100644 index 0000000..07c5a9f --- /dev/null +++ b/app/Models/TempStmtEntry.php @@ -0,0 +1,24 @@ +id(); + foreach ($fieldsArray as $field) { + $field = trim($field); + $table->string($field)->nullable(); + } + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('temp_stmt_entry'); + } +};