A free open source IT asset/license management system
Fixes/cli importer issue (#9199)
Ivan Nieto Vivanco90a24539b00f
diff --git a/app/Importer/AssetImporter.php b/app/Importer/AssetImporter.phpindex bdc254cb06..be117d6fae 100644--- a/app/Importer/AssetImporter.php+++ b/app/Importer/AssetImporter.php@@ -120,8 +120,10 @@ 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 setted by+ //-- the class that needs to use it (command importer or GUI importer inside the project).if(isset($target)) {- $asset->fresh()->checkOut($target);+ $asset->fresh()->checkOut($target, $this->user_id);}return;}diff --git a/app/Models/Asset.php b/app/Models/Asset.phpindex f84c2ca707..813fb6d3a4 100644--- a/app/Models/Asset.php+++ b/app/Models/Asset.php@@ -313,8 +313,14 @@ class Asset extends Depreciable}if ($this->save()) {-- event(new CheckoutableCheckedOut($this, $target, Auth::user(), $note));+ if (is_integer($admin)){+ $checkedOutBy = User::findOrFail($admin);+ } elseif (get_class($admin) === 'App\Models\User') {+ $checkedOutBy = $admin;+ } else {+ $checkedOutBy = Auth::user();+ }+ event(new CheckoutableCheckedOut($this, $target, $checkedOutBy, $note));$this->increment('checkout_counter', 1);return true;