A free open source IT asset/license management system
Add ability to checkout an asset if the user it’s assigned_to isn’t valid
snipe30d68309a907
diff --git a/app/Models/Asset.php b/app/Models/Asset.phpindex 9af62593d7..1492f5a443 100644--- a/app/Models/Asset.php+++ b/app/Models/Asset.php@@ -232,7 +232,10 @@ class Asset extends Depreciable}/**- * Determines if an asset is available for checkout+ * Determines if an asset is available for checkout.+ * This checks to see if the it's checked out to an invalid (deleted) user+ * OR if the assigned_to and deleted_at fields on the asset are empty AND+ * that the status is deployable** @author [A. Gianotto] [<[email protected]>]* @since [v3.0]@@ -241,9 +244,10 @@ class Asset extends Depreciablepublic function availableForCheckout(){if (- (empty($this->assigned_to)) &&+ (!$this->assignedTo) ||+ ((empty($this->assigned_to)) &&(empty($this->deleted_at)) &&- (($this->assetstatus) && ($this->assetstatus->deployable == 1)))+ (($this->assetstatus) && ($this->assetstatus->deployable == 1)))){return true;}@@ -424,7 +428,7 @@ class Asset extends Depreciable*/public function assignedTo(){- return $this->morphTo('assigned', 'assigned_type', 'assigned_to');+ return $this->morphTo('assigned', 'assigned_type', 'assigned_to')->withTrashed();}/**