Skip to content

Commit

Permalink
Evaluate if the event properties exists before run the CheckoutAccept…
Browse files Browse the repository at this point in the history
…ance query
  • Loading branch information
inietov committed Sep 13, 2023
1 parent 3cf9c1f commit 439e031
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/Listeners/CheckoutableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ public function onCheckedIn($event)
/**
* 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();
}
}
}

Expand Down

0 comments on commit 439e031

Please sign in to comment.