Updated skip logic if duplicate plant found
This commit is contained in:
@@ -46,6 +46,19 @@ class PlantImporter extends Importer
|
|||||||
public function resolveRecord(): ?Plant
|
public function resolveRecord(): ?Plant
|
||||||
{
|
{
|
||||||
$company = \App\Models\Company::where('name', $this->data['company'])->first();
|
$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([
|
return Plant::updateOrCreate([
|
||||||
'code' => $this->data['code'],
|
'code' => $this->data['code'],
|
||||||
'name' => $this->data['name'],
|
'name' => $this->data['name'],
|
||||||
|
|||||||
Reference in New Issue
Block a user