mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 13:57:41 -08:00
Fixed #8794 - Switched to firstOrCreate to create parents on import
This commit is contained in:
parent
e9bfb157bb
commit
c0d7564658
|
@ -88,11 +88,13 @@ class ImportLocations extends Command
|
||||||
|
|
||||||
if (array_key_exists('Parent Name', $row)) {
|
if (array_key_exists('Parent Name', $row)) {
|
||||||
$parent_name = trim($row['Parent Name']);
|
$parent_name = trim($row['Parent Name']);
|
||||||
|
} else {
|
||||||
|
$parent_name = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the location attributes to save
|
// Set the location attributes to save
|
||||||
if (array_key_exists('Name', $row)) {
|
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']);
|
$location->name = trim($row['Name']);
|
||||||
$this->info('Checking location: '.$location->name);
|
$this->info('Checking location: '.$location->name);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue