diff --git a/app/Jobs/ProcessAccountDataJob.php b/app/Jobs/ProcessAccountDataJob.php new file mode 100644 index 0000000..6fd7cde --- /dev/null +++ b/app/Jobs/ProcessAccountDataJob.php @@ -0,0 +1,68 @@ +getFillable(); + while (($row = fgetcsv($handle, 0, ";")) !== false) { + if (count($headers) === count($row)) { + $data = array_combine($headers, $row); + + try { + TempAccount::updateOrCreate(['account_number' => $data['account_number']], $data); + } catch (Exception $e) { + Log::error('Error processing Account: ' . $e->getMessage()); + } + } + } + fclose($handle); + } else { + throw new Exception("Unable to open file: {$filePath}"); + } + } catch (Exception $e) { + Log::error('Error in ProcessAccountDataJob: ' . $e->getMessage()); + throw $e; + } + } + } diff --git a/app/Models/TempAccount.php b/app/Models/TempAccount.php new file mode 100644 index 0000000..2776a63 --- /dev/null +++ b/app/Models/TempAccount.php @@ -0,0 +1,27 @@ +id(); + + foreach ($fieldArray as $field) { + $field = trim($field); + $table->text($field)->nullable(); + } + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('temp_accounts'); + } +};