diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 3e4d2906..49cde869 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -4336,7 +4336,16 @@ class APIController extends Controller implements LoggedController foreach ($nearest_hubs_with_distance as $nhd) { if (empty($nearest)) - $nearest = $nhd; + { + // get the slots for the hub to check if hub is available for assignment + $hub_slots = $this->getHubRiderSlots($nhd['hub'], $em); + + $flag_hub_available = $hub_slots['flag_hub_available']; + if ($flag_hub_available == true) + { + $nearest = $nhd; + } + } else { if ($nhd['distance'] < $nearest['distance'])