mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
a few more imports, component sample
This commit is contained in:
parent
abf13f1619
commit
3574ef5bb9
|
@ -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;
|
||||
|
|
|
@ -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()) {
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
2
sample_csvs/components-sample.csv
Normal file
2
sample_csvs/components-sample.csv
Normal 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
|
|
Loading…
Reference in a new issue