A free open source IT asset/license management system
Fixed #16097 - allow location update by ID in importer
snipe801328ec42d5
diff --git a/app/Importer/Importer.php b/app/Importer/Importer.phpindex 907c8b72c5..0d4b8d4932 100644--- a/app/Importer/Importer.php+++ b/app/Importer/Importer.php@@ -39,6 +39,7 @@ abstract class Importer* @var array*/private $defaultFieldMap = [+ 'id' => 'id','asset_tag' => 'asset tag','activated' => 'activated','category' => 'category',diff --git a/app/Importer/ItemImporter.php b/app/Importer/ItemImporter.phpindex 6b1d647136..435f081aba 100644--- a/app/Importer/ItemImporter.php+++ b/app/Importer/ItemImporter.php@@ -456,14 +456,13 @@ class ItemImporter extends Importer{if (empty($asset_location)) {$this->log('No location given, so none created.');-return null;}+$location = Location::where(['name' => $asset_location])->first();if ($location) {$this->log('Location '.$asset_location.' already exists');-return $location->id;}// No matching locations in the collection, create a new one.diff --git a/app/Importer/LocationImporter.php b/app/Importer/LocationImporter.phpindex a9a5152234..b875d66c6a 100644--- a/app/Importer/LocationImporter.php+++ b/app/Importer/LocationImporter.php@@ -38,7 +38,14 @@ class LocationImporter extends ItemImporter{$editingLocation = false;- $location = Location::where('name', '=', $this->findCsvMatch($row, 'name'))->first();++ if ($this->findCsvMatch($row, 'id')) {+ $location = Location::find($this->findCsvMatch($row, 'id'));+ } else {+ $location = Location::where('name', '=', $this->findCsvMatch($row, 'name'))->first();+ }++if ($location) {if (! $this->updating) {diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.phpindex 75b707b8ad..aee6b852d4 100644--- a/app/Livewire/Importer.php+++ b/app/Livewire/Importer.php@@ -329,6 +329,7 @@ class Importer extends Component];$this->locations_fields = [+ 'id' => trans('general.id'),'name' => trans('general.item_name_var', ['item' => trans('general.location')]),'address' => trans('general.address'),'address2' => trans('general.importer.address2'),@@ -400,7 +401,6 @@ class Importer extends Component'requestable','Requestable',],-'gravatar' =>['gravatar',