diff --git a/app/Classes/Modules/Orders/Services/ListsOrderHistory.php b/app/Classes/Modules/Orders/Services/ListsOrderHistory.php index c3401f5..53ec1e8 100644 --- a/app/Classes/Modules/Orders/Services/ListsOrderHistory.php +++ b/app/Classes/Modules/Orders/Services/ListsOrderHistory.php @@ -47,8 +47,12 @@ class ListsOrderHistory $shippingSchedules = $shippingArrangment->shippingSchedule()->get(); foreach ($shippingSchedules as $schedule){ if($schedule->status === "2"){ - $customeIssue = CustomIssues::where('schedule_id', $schedule->id)->firstOrFail(); - $history->push(['date' => $step->updated_at->format('d-m-Y H:i'), 'description' => '[ETD: '.$schedule->ETD.', ETA: '.$schedule->ETA.'] Shipping Schedule failed due to: '.$customeIssue->remark]); + $customeIssue = CustomIssues::where('schedule_id', $schedule->id)->first(); + if($customeIssue){ + $history->push(['date' => $step->updated_at->format('d-m-Y H:i'), 'description' => '[ETD: '.$schedule->ETD.', ETA: '.$schedule->ETA.'] Shipping Schedule failed due to: '.$customeIssue->remark]); + } else { + $history->push(['date' => $step->updated_at->format('d-m-Y H:i'), 'description' => '[ETD: '.$schedule->ETD.', ETA: '.$schedule->ETA.'] Shipping Schedule failed']); + } } else { $history->push(['date' => $step->updated_at->format('d-m-Y H:i'), 'description' => '[ETD: '.$schedule->ETD.', ETA: '.$schedule->ETA.'] Your Order has been scheduled for shipping ']); } @@ -76,7 +80,11 @@ class ListsOrderHistory foreach ($shippingSchedules as $schedule){ if($schedule->status === "2"){ $customeIssue = CustomIssues::where('schedule_id', $schedule->id)->firstOrFail(); - $history->push(['date' => $step->updated_at->format('d-m-Y H:i'), 'description' => '[ETD: '.$schedule->ETD.', ETA: '.$schedule->ETA.'] Shipping Schedule failed due to: '.$customeIssue->remark]); + if($customeIssue){ + $history->push(['date' => $step->updated_at->format('d-m-Y H:i'), 'description' => '[ETD: '.$schedule->ETD.', ETA: '.$schedule->ETA.'] Shipping Schedule failed due to: '.$customeIssue->remark]); + } else { + $history->push(['date' => $step->updated_at->format('d-m-Y H:i'), 'description' => '[ETD: '.$schedule->ETD.', ETA: '.$schedule->ETA.'] Shipping Schedule failed']); + } } else { $history->push(['date' => $step->updated_at->format('d-m-Y H:i'), 'description' => '[ETD: '.$schedule->ETD.', ETA: '.$schedule->ETA.'] Your Order has been scheduled for shipping ']); }