Skip to content

Commit

Permalink
Check for matching ID
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <[email protected]>
  • Loading branch information
snipe committed Jan 20, 2025
1 parent 713c9fd commit 5273408
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Importer/LocationImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ public function createLocationIfNotExists(array $row)

$editingLocation = false;

$location = Location::where('name', '=', $this->findCsvMatch($row, 'name'))->first();

if ($this->findCsvMatch($row, 'id')!='') {
// Override location if an ID was given
\Log::debug('Finding location by ID: '.$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) {
$this->log('A matching Location '.$this->item['name'].' already exists');
Expand Down

0 comments on commit 5273408

Please sign in to comment.