a few more imports, component sample

This commit is contained in:
spencerrlongg 2024-01-25 19:54:53 -06:00
parent abf13f1619
commit 3574ef5bb9
6 changed files with 14 additions and 7 deletions

View file

@ -46,10 +46,9 @@ class AccessoryImporter extends ItemImporter
$this->item['min_amt'] = $this->findCsvMatch($row, "min_amt");
$accessory->fill($this->sanitizeItemForStoring($accessory));
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
// $accessory->unsetEventDispatcher();
// This sets an attribute on the Loggable trait for the action log
$accessory->setImported(true);
if ($accessory->save()) {
$accessory->logCreate('Imported using CSV Importer');
$this->log('Accessory '.$this->item['name'].' was created');
return;

View file

@ -135,7 +135,7 @@ class AssetImporter extends ItemImporter
$asset->{$custom_field} = $val;
}
}
//this sets an attribute on the Loggable trait for the action log
// This sets an attribute on the Loggable trait for the action log
$asset->setImported(true);
if ($asset->save()) {

View file

@ -48,10 +48,10 @@ class ComponentImporter extends ItemImporter
$this->log('No matching component, creating one');
$component = new Component;
$component->fill($this->sanitizeItemForStoring($component));
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
$component->unsetEventDispatcher();
// This sets an attribute on the Loggable trait for the action log
$component->setImported(true);
if ($component->save()) {
$component->logCreate('Imported using CSV Importer');
$this->log('Component '.$this->item['name'].' was created');
// If we have an asset tag, checkout to that asset.

View file

@ -38,6 +38,9 @@ class AccessoryObserver
$logAction->item_id = $accessory->id;
$logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id();
if($accessory->imported) {
$logAction->note = trans('general.importer.import_note');
}
$logAction->logaction('create');
}

View file

@ -38,6 +38,9 @@ class ComponentObserver
$logAction->item_id = $component->id;
$logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id();
if($component->imported) {
$logAction->note = trans('general.importer.import_note');
}
$logAction->logaction('create');
}

View file

@ -0,0 +1,2 @@
Item Name,Purchase Date,Purchase Cost,Location,Company,Order Number,Serial number,Category,Quantity
RTX 4080,2024-01-01,5000.00,Austin,Grokability,2790,123456789,GPU,10
1 Item Name Purchase Date Purchase Cost Location Company Order Number Serial number Category Quantity
2 RTX 4080 2024-01-01 5000.00 Austin Grokability 2790 123456789 GPU 10