From 1030ad9a2704b8bbca970e775d62fd9469dd6b9a Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Mon, 6 Jun 2022 22:00:05 -0500 Subject: [PATCH] Early returns if no change is made in the Asset so the 'update' action doesn't log --- app/Observers/AssetObserver.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Observers/AssetObserver.php b/app/Observers/AssetObserver.php index 6d9f37c317..f0a23eb07c 100644 --- a/app/Observers/AssetObserver.php +++ b/app/Observers/AssetObserver.php @@ -26,7 +26,7 @@ class AssetObserver && ($attributes['checkout_counter'] == $attributesOriginal['checkout_counter']) && ($attributes['checkin_counter'] == $attributesOriginal['checkin_counter']) && ((isset( $attributes['next_audit_date']) ? $attributes['next_audit_date'] : null) == (isset($attributesOriginal['next_audit_date']) ? $attributesOriginal['next_audit_date']: null)) - && ($attributes['last_checkout'] == $attributesOriginal['last_checkout'])) + && ($attributes['last_checkout'] == $attributesOriginal['last_checkout'])) { $changed = []; @@ -35,7 +35,11 @@ class AssetObserver $changed[$key]['old'] = $asset->getRawOriginal()[$key]; $changed[$key]['new'] = $asset->getAttributes()[$key]; } - } + } + + if (empty($changed)){ + return; + } $logAction = new Actionlog(); $logAction->item_type = Asset::class;