From 0ae1db6fe325c395a0a34d08fc059869ad84cf83 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 13 Nov 2024 18:20:47 +0000 Subject: [PATCH] Added created_by Signed-off-by: snipe --- app/Importer/ComponentImporter.php | 3 ++- app/Importer/ConsumableImporter.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Importer/ComponentImporter.php b/app/Importer/ComponentImporter.php index 9687ec4f17..3979ba499d 100644 --- a/app/Importer/ComponentImporter.php +++ b/app/Importer/ComponentImporter.php @@ -47,6 +47,7 @@ class ComponentImporter extends ItemImporter } $this->log('No matching component, creating one'); $component = new Component; + $component->created_by = auth()->id(); $component->fill($this->sanitizeItemForStoring($component)); // This sets an attribute on the Loggable trait for the action log @@ -58,7 +59,7 @@ class ComponentImporter extends ItemImporter if (isset($this->item['asset_tag']) && ($asset = Asset::where('asset_tag', $this->item['asset_tag'])->first())) { $component->assets()->attach($component->id, [ 'component_id' => $component->id, - 'created_by' => $this->created_by, + 'created_by' => auth()->id(), 'created_at' => date('Y-m-d H:i:s'), 'assigned_qty' => 1, // Only assign the first one to the asset 'asset_id' => $asset->id, diff --git a/app/Importer/ConsumableImporter.php b/app/Importer/ConsumableImporter.php index 9e7019b086..10ffaaedfb 100644 --- a/app/Importer/ConsumableImporter.php +++ b/app/Importer/ConsumableImporter.php @@ -41,6 +41,7 @@ class ConsumableImporter extends ItemImporter } $this->log('No matching consumable, creating one'); $consumable = new Consumable(); + $consumable->created_by = auth()->id(); $this->item['model_number'] = trim($this->findCsvMatch($row, 'model_number')); $this->item['item_no'] = trim($this->findCsvMatch($row, 'item_number')); $this->item['min_amt'] = trim($this->findCsvMatch($row, "min_amt"));