Evaluate if the event properties exists before run the CheckoutAcceptance query

This commit is contained in:
Ivan Nieto Vivanco 2023-09-13 16:35:10 -06:00
parent 3cf9c1fea5
commit 439e031911

View file

@ -79,8 +79,9 @@ class CheckoutableListener
/**
* Send the appropriate notification
*/
$acceptances = CheckoutAcceptance::where('checkoutable_id', $event->checkoutable->id ?? null)
->where('assigned_to_id', $event->checkedOutTo->id ?? null)
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){
@ -88,6 +89,7 @@ class CheckoutableListener
$acceptance->delete();
}
}
}
try {
if ($this->shouldSendWebhookNotification()) {