mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Fix double create log on import. (#4706)
* Fix double create log on import. * Fix code error causing component importer to implode. * More component importer oldities
This commit is contained in:
parent
b721bfcc84
commit
b2469bb34f
|
@ -41,6 +41,7 @@ class AccessoryImporter extends ItemImporter
|
|||
$this->log("No Matching Accessory, Creating a new one");
|
||||
$accessory = new Accessory();
|
||||
$accessory->fill($this->sanitizeItemForStoring($accessory));
|
||||
$accessory->unsetEventDispatcher();
|
||||
if ($accessory->save()) {
|
||||
$accessory->logCreate('Imported using CSV Importer');
|
||||
$this->log('Accessory ' . $this->item["name"] . ' was created');
|
||||
|
|
|
@ -106,6 +106,7 @@ class AssetImporter extends ItemImporter
|
|||
$asset->{$custom_field} = $val;
|
||||
}
|
||||
}
|
||||
$asset->unsetEventDispatcher();
|
||||
if ($asset->save()) {
|
||||
$asset->logCreate('Imported using csv importer');
|
||||
$this->log('Asset ' . $this->item["name"] . ' with serial number ' . $this->item['serial'] . ' was created');
|
||||
|
|
|
@ -27,29 +27,26 @@ class ComponentImporter extends ItemImporter
|
|||
public function createComponentIfNotExists()
|
||||
{
|
||||
$component = null;
|
||||
$editingComponent = false;
|
||||
$this->log("Creating Component");
|
||||
$component = Component::where('name', $this->item['name'])
|
||||
->where('serial', $this->item['serial'])
|
||||
->first();
|
||||
|
||||
if ($component) {
|
||||
$editingComponent = true;
|
||||
$this->log('A matching Component ' . $this->item["name"] . ' with serial ' .$this->item['serial'].' already exists. ');
|
||||
if (!$this->updating) {
|
||||
$this->log("Skipping Component");
|
||||
return;
|
||||
}
|
||||
$this->log("Updating Component");
|
||||
$component = $this->components[$componentId];
|
||||
$component->update($this->sanitizeItemFor($component));
|
||||
$component->update($this->sanitizeItemForUpdating($component));
|
||||
$component->save();
|
||||
return;
|
||||
}
|
||||
$this->log("No matching component, creating one");
|
||||
$component = new Component;
|
||||
$component->fill($$this->sanitizeItemForStoring($component));
|
||||
|
||||
$component->fill($this->sanitizeItemForStoring($component));
|
||||
$component->unsetEventDispatcher();
|
||||
if ($component->save()) {
|
||||
$component->logCreate('Imported using CSV Importer');
|
||||
$this->log("Component " . $this->item["name"] . ' was created');
|
||||
|
|
|
@ -41,6 +41,7 @@ class ConsumableImporter extends ItemImporter
|
|||
$consumable = new Consumable();
|
||||
$consumable->fill($this->sanitizeItemForStoring($consumable));
|
||||
|
||||
$consumable->unsetEventDispatcher();
|
||||
if ($consumable->save()) {
|
||||
$consumable->logCreate('Imported using CSV Importer');
|
||||
$this->log("Consumable " . $this->item["name"] . ' was created');
|
||||
|
|
|
@ -63,6 +63,8 @@ class LicenseImporter extends ItemImporter
|
|||
} else {
|
||||
$license->fill($this->sanitizeItemForStoring($license));
|
||||
}
|
||||
|
||||
$license->unsetEventDispatcher();
|
||||
if ($license->save()) {
|
||||
$license->logCreate('Imported using csv importer');
|
||||
$this->log('License ' . $this->item["name"] . ' with serial number ' . $this->item['serial'] . ' was created');
|
||||
|
|
|
@ -182,7 +182,7 @@ trait Loggable
|
|||
$log->location_id = null;
|
||||
$log->note = $note;
|
||||
$log->user_id = $user_id;
|
||||
$log->logaction('created');
|
||||
$log->logaction('create');
|
||||
$log->save();
|
||||
return $log;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue