diff --git a/app/Jobs/ProcessStmtNarrParamDataJob.php b/app/Jobs/ProcessStmtNarrParamDataJob.php new file mode 100644 index 0000000..72a4419 --- /dev/null +++ b/app/Jobs/ProcessStmtNarrParamDataJob.php @@ -0,0 +1,68 @@ +getFillable(); + while (($row = fgetcsv($handle, 0, ";")) !== false) { + if (count($headers) === count($row)) { + $data = array_combine($headers, $row); + + try { + TempStmtNarrParam::updateOrCreate(['_id' => $data['_id']], $data); + } catch (Exception $e) { + Log::error('Error processing stmt narr param: ' . $e->getMessage()); + } + } + } + fclose($handle); + } else { + throw new Exception("Unable to open file: {$filePath}"); + } + } catch (Exception $e) { + Log::error('Error in ProcessStmtNarrParamDataJob: ' . $e->getMessage()); + throw $e; + } + } + } diff --git a/app/Models/TempStmtNarrParam.php b/app/Models/TempStmtNarrParam.php new file mode 100644 index 0000000..7e5721c --- /dev/null +++ b/app/Models/TempStmtNarrParam.php @@ -0,0 +1,23 @@ +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_narr_param'); + } +};