From 9f7f1460e9c2efa92f56cc77e8da642d86473cff Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 26 Jan 2021 22:12:24 -0800 Subject: [PATCH] Simplified availableForCheckout() on asset --- app/Models/Asset.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 86b30347ba..f84c2ca707 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -246,13 +246,18 @@ class Asset extends Depreciable */ public function availableForCheckout() { - if ( - ((!$this->assignedTo) && ($this->assetstatus->archived == 0)) || - ((empty($this->assigned_to)) && - (empty($this->deleted_at)) && - (($this->assetstatus) && ($this->assetstatus->deployable == 1)))) - { - return true; + + // This asset is not currently assigned to anyone and is not deleted... + if ((!$this->assigned_to) && (!$this->deleted_at)) { + + // The asset status is not archived and is deployable + if (($this->assetstatus) && ($this->assetstatus->archived == '0') + && ($this->assetstatus->deployable == '1')) + { + + return true; + } + } return false; }