feat: sort services
This commit is contained in:
@@ -74,18 +74,30 @@ class Travel
|
|||||||
{
|
{
|
||||||
$group = (array) $group;
|
$group = (array) $group;
|
||||||
|
|
||||||
return array_filter($this->additionalServices, function (Service $service) use ($group, $availableOnly) {
|
$services = array_filter($this->additionalServices, function (Service $service) use ($group, $availableOnly) {
|
||||||
return in_array($service->subType, $group) && (false === $availableOnly || $service->available > 0);
|
return in_array($service->subType, $group) && (false === $availableOnly || $service->available > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
usort($services, function (Service $a, Service $b) {
|
||||||
|
return $a->label <=> $b->label;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTransportationServicesByDirection(string $direction, bool $availableOnly = true): array
|
public function getTransportationServicesByDirection(string $direction, bool $availableOnly = true): array
|
||||||
{
|
{
|
||||||
return array_filter($this->transportationServices, function (Service $service) use ($direction, $availableOnly) {
|
$services = array_filter($this->transportationServices, function (Service $service) use ($direction, $availableOnly) {
|
||||||
return $direction === $service->direction
|
return $direction === $service->direction
|
||||||
&& $service->price >= 0
|
&& $service->price >= 0
|
||||||
&& (false === $availableOnly || $service->available > 0);
|
&& (false === $availableOnly || $service->available > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
usort($services, function (Service $a, Service $b) {
|
||||||
|
return $a->subType <=> $b->subType;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIncludedServices(): array
|
public function getIncludedServices(): array
|
||||||
|
|||||||
Reference in New Issue
Block a user