Updated skip logic if duplicate plant found

This commit is contained in:
dhanabalan
2025-04-28 00:14:33 +05:30
parent c8e2a9c7b9
commit 2c1efb1bf0

View File

@@ -46,6 +46,19 @@ class PlantImporter extends Importer
public function resolveRecord(): ?Plant
{
$company = \App\Models\Company::where('name', $this->data['company'])->first();
if (!$company) {
return null;
}
$plantCN = \App\Models\Plant::where('code', $this->data['code'])->where('name', $this->data['name'])->first();
if (!$plantCN) {
$plantCode = \App\Models\Plant::where('code', $this->data['code'])->first();
$plantName = \App\Models\Plant::where('name', $this->data['name'])->first();
if ($plantCode || $plantName) {
return null;
}
}
return Plant::updateOrCreate([
'code' => $this->data['code'],
'name' => $this->data['name'],