Added update or create record on import

This commit is contained in:
dhanabalan
2025-04-25 12:56:08 +05:30
parent 58a58f3d9b
commit 81640fda90
2 changed files with 46 additions and 2 deletions

View File

@@ -45,12 +45,22 @@ class PlantImporter extends Importer
public function resolveRecord(): ?Plant
{
$company = \App\Models\Company::where('name', $this->data['company'])->first();
return Plant::updateOrCreate([
'code' => $this->data['code'],
'name' => $this->data['name'],
],
[
'address' => $this->data['address'],
'company_id' => $company->id
]
);
// return Plant::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new Plant();
// return new Plant();
}
public static function getCompletedNotificationBody(Import $import): string