Added update or create record on import
This commit is contained in:
@@ -45,12 +45,17 @@ class ItemImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Item
|
||||
{
|
||||
// return Item::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Item;
|
||||
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
|
||||
return Item::updateOrCreate([
|
||||
'code' => $this->data['code'],
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'description' => $this->data['description'],
|
||||
'hourly_quantity' => $this->data['hourly_quantity']
|
||||
]
|
||||
);
|
||||
// return new Item;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
Reference in New Issue
Block a user