A free open source IT asset/license management system
Fixed component checkout bug (#5282)
snipeedb81425cfec
diff --git a/app/Models/Asset.php b/app/Models/Asset.phpindex 0e5121dd83..e7279ebd61 100644--- a/app/Models/Asset.php+++ b/app/Models/Asset.php@@ -24,7 +24,7 @@ use App\Notifications\CheckoutAssetNotification;class Asset extends Depreciable{protected $presenter = 'App\Presenters\AssetPresenter';- use Loggable, Requestable, Presentable, Notifiable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait;+ use Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait;const LOCATION = 'location';const ASSET = 'asset';diff --git a/app/Models/Component.php b/app/Models/Component.phpindex 38610277bb..f7b9bb9fcd 100644--- a/app/Models/Component.php+++ b/app/Models/Component.php@@ -19,6 +19,14 @@ class Component extends SnipeModelprotected $dates = ['deleted_at', 'purchase_date'];protected $table = 'components';++ /**+ * Set static properties to determine which checkout/checkin handlers we should use+ */+ public static $checkoutClass = null;+ public static $checkinClass = null;++/*** Category validation rules*/diff --git a/app/Models/Loggable.php b/app/Models/Loggable.phpindex cd392f51b7..1a8cf3676a 100644--- a/app/Models/Loggable.php+++ b/app/Models/Loggable.php@@ -73,16 +73,16 @@ trait Loggable'settings' => $settings,];-- // Send to the admin, if settings dictate- $recipient = new \App\Models\Recipients\AdminRecipient();-+ $checkoutClass = null;if (method_exists($target, 'notify')) {$target->notify(new static::$checkoutClass($params));}- if ($settings->admin_cc_email!='') {+ // Send to the admin, if settings dictate+ $recipient = new \App\Models\Recipients\AdminRecipient();++ if (($settings->admin_cc_email!='') && (static::$checkoutClass!='')) {$recipient->notify(new static::$checkoutClass($params));}@@ -140,8 +140,6 @@ trait Loggable'settings' => $settings,];- // Send to the admin, if settings dictate- $recipient = new \App\Models\Recipients\AdminRecipient();$checkoutClass = null;@@ -149,7 +147,10 @@ trait Loggable$target->notify(new static::$checkinClass($params));}- if ($settings->admin_cc_email!='') {+ // Send to the admin, if settings dictate+ $recipient = new \App\Models\Recipients\AdminRecipient();++ if (($settings->admin_cc_email!='') && (static::$checkoutClass!='')) {$recipient->notify(new static::$checkinClass($params));}