Skip to content

A free open source IT asset/license management system

Evaluate if the event properties exists before run the CheckoutAcceptance query

Ivan Nieto Vivanco439e031911fd
diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php
index fc86245d1a..2c27e19ecf 100644
--- a/app/Listeners/CheckoutableListener.php
+++ b/app/Listeners/CheckoutableListener.php
@@ -79,13 +79,15 @@ class CheckoutableListener
/**
* Send the appropriate notification
*/
- $acceptances = CheckoutAcceptance::where('checkoutable_id', $event->checkoutable->id ?? null)
- ->where('assigned_to_id', $event->checkedOutTo->id ?? null)
- ->get();
-
- foreach($acceptances as $acceptance){
- if($acceptance->isPending()){
- $acceptance->delete();
+ if ($event->checkedOutTo && $event->checkoutable){
+ $acceptances = CheckoutAcceptance::where('checkoutable_id', $event->checkoutable->id)
+ ->where('assigned_to_id', $event->checkedOutTo->id)
+ ->get();
+
+ foreach($acceptances as $acceptance){
+ if($acceptance->isPending()){
+ $acceptance->delete();
+ }
}
}