From c0d7564658d65b6e80ae231ac5ca11d0a2c96842 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 24 Nov 2020 16:05:24 -0800 Subject: [PATCH] Fixed #8794 - Switched to firstOrCreate to create parents on import --- app/Console/Commands/ImportLocations.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/ImportLocations.php b/app/Console/Commands/ImportLocations.php index f36a384c1..a0512aa39 100644 --- a/app/Console/Commands/ImportLocations.php +++ b/app/Console/Commands/ImportLocations.php @@ -88,11 +88,13 @@ class ImportLocations extends Command if (array_key_exists('Parent Name', $row)) { $parent_name = trim($row['Parent Name']); + } else { + $parent_name = null; } // Set the location attributes to save if (array_key_exists('Name', $row)) { - $location = Location::firstOrNew(array('name' => trim($row['Name']))); + $location = Location::firstOrCreate(array('name' => trim($row['Name']))); $location->name = trim($row['Name']); $this->info('Checking location: '.$location->name); } else {