From 4363e8b34c2b94d94543a6988fd026449a01e04a Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 19 Sep 2024 16:20:42 +0100 Subject: [PATCH] Updated importer Signed-off-by: snipe --- app/Importer/AssetImporter.php | 2 +- app/Importer/ComponentImporter.php | 2 +- app/Importer/Importer.php | 10 +++++----- app/Importer/ItemImporter.php | 2 +- app/Importer/LocationImporter.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Importer/AssetImporter.php b/app/Importer/AssetImporter.php index b465ec844e..1112a04e35 100644 --- a/app/Importer/AssetImporter.php +++ b/app/Importer/AssetImporter.php @@ -177,7 +177,7 @@ class AssetImporter extends ItemImporter $this->log('Asset '.$this->item['name'].' with serial number '.$this->item['serial'].' was created'); // If we have a target to checkout to, lets do so. - //-- user_id is a property of the abstract class Importer, which this class inherits from and it's set by + //-- created_by is a property of the abstract class Importer, which this class inherits from and it's set by //-- the class that needs to use it (command importer or GUI importer inside the project). if (isset($target) && ($target !== false)) { if (!is_null($asset->assigned_to)){ diff --git a/app/Importer/ComponentImporter.php b/app/Importer/ComponentImporter.php index 125fbdbbef..9687ec4f17 100644 --- a/app/Importer/ComponentImporter.php +++ b/app/Importer/ComponentImporter.php @@ -58,7 +58,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, - 'user_id' => $this->created_by, + 'created_by' => $this->created_by, '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/Importer.php b/app/Importer/Importer.php index 1557a5236f..678fb9ecb2 100644 --- a/app/Importer/Importer.php +++ b/app/Importer/Importer.php @@ -22,7 +22,7 @@ abstract class Importer * @var */ - protected $user_id; + protected $created_by; /** * Are we updating items in the import * @var bool @@ -395,7 +395,7 @@ abstract class Importer } /** - * Matches a user by user_id if user_name provided is a number + * Matches a user by created_by if user_name provided is a number * @param string $user_name users full name from csv * @return User User Matching ID */ @@ -412,13 +412,13 @@ abstract class Importer /** * Sets the Id of User performing import. * - * @param mixed $user_id the user id + * @param mixed $created_by the user id * * @return self */ - public function setUserId($user_id) + public function setUserId($created_by) { - $this->created_by = $user_id; + $this->created_by = $created_by; return $this; } diff --git a/app/Importer/ItemImporter.php b/app/Importer/ItemImporter.php index 6043ef0940..360618f4f0 100644 --- a/app/Importer/ItemImporter.php +++ b/app/Importer/ItemImporter.php @@ -94,7 +94,7 @@ class ItemImporter extends Importer $this->item['qty'] = $this->findCsvMatch($row, 'quantity'); $this->item['requestable'] = $this->findCsvMatch($row, 'requestable'); - $this->item['user_id'] = $this->created_by; + $this->item['created_by'] = $this->created_by; $this->item['serial'] = $this->findCsvMatch($row, 'serial'); // NO need to call this method if we're running the user import. // TODO: Merge these methods. diff --git a/app/Importer/LocationImporter.php b/app/Importer/LocationImporter.php index e344b6beaf..b3ef59d248 100644 --- a/app/Importer/LocationImporter.php +++ b/app/Importer/LocationImporter.php @@ -65,7 +65,7 @@ class LocationImporter extends ItemImporter $this->item['ldap_ou'] = trim($this->findCsvMatch($row, 'ldap_ou')); $this->item['manager'] = trim($this->findCsvMatch($row, 'manager')); $this->item['manager_username'] = trim($this->findCsvMatch($row, 'manager_username')); - $this->item['user_id'] = auth()->id(); + $this->item['created_by'] = auth()->id(); if ($this->findCsvMatch($row, 'parent_location')) { $this->item['parent_id'] = $this->createOrFetchLocation(trim($this->findCsvMatch($row, 'parent_location')));