wip: improved insurance selection

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 16c239716b
commit 4489169553
6 changed files with 91 additions and 17 deletions
+4 -6
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\BusProNet\Model;
use App\BusProNet\Constants;
use App\BusProNet\Traits\SortByPriceTrait;
use Symfony\Component\Serializer\Attribute\Context;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
@@ -18,6 +19,7 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
*/
class Travel
{
use SortByPriceTrait;
#[Groups(['api:list', 'api:single'])]
public ?int $id = null;
@@ -98,7 +100,7 @@ class Travel
* Filters additional services based on the provided subtype(s), availability,
* and optionally whether their date range overlaps with the travel dates.
* Services with null dates are considered always available when date filtering is enabled.
* Services are sorted alphabetically by label.
* Services are sorted by price in ascending order.
*
* @param mixed $subTypes The service subtype(s) to filter by
* @param bool $filterAvailable Whether to include only available services
@@ -135,11 +137,7 @@ class Travel
return true;
});
usort($services, function (Service $a, Service $b) {
return $a->label <=> $b->label;
});
return $services;
return $this->sortByPrice($services);
}
/**