From 3cf9c1fea536ea22289b275b28a1ccaf311b0028 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 30 Aug 2023 11:57:29 -0600 Subject: [PATCH 1/2] Adds a null coalescing operator to the license seat checkin notification --- app/Listeners/CheckoutableListener.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index 09cb3ae8f2..fc86245d1a 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -79,8 +79,8 @@ class CheckoutableListener /** * Send the appropriate notification */ - $acceptances = CheckoutAcceptance::where('checkoutable_id', $event->checkoutable->id) - ->where('assigned_to_id', $event->checkedOutTo->id) + $acceptances = CheckoutAcceptance::where('checkoutable_id', $event->checkoutable->id ?? null) + ->where('assigned_to_id', $event->checkedOutTo->id ?? null) ->get(); foreach($acceptances as $acceptance){ From 439e031911fd92f6b8317160e2351ff12362c34a Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 13 Sep 2023 16:35:10 -0600 Subject: [PATCH 2/2] Evaluate if the event properties exists before run the CheckoutAcceptance query --- app/Listeners/CheckoutableListener.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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(); + 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(); + foreach($acceptances as $acceptance){ + if($acceptance->isPending()){ + $acceptance->delete(); + } } }