#45 sort orderitems aplhabetically in order view show
All checks were successful
/ ls (pull_request) Successful in 35s
All checks were successful
/ ls (pull_request) Successful in 35s
This commit is contained in:
parent
add3631376
commit
83989916a3
3 changed files with 74 additions and 1 deletions
|
@ -99,6 +99,22 @@ class FoodOrder
|
|||
return $this->orderItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, OrderItem>
|
||||
*/
|
||||
public function getOrderItemsSortedByName(): Collection
|
||||
{
|
||||
$iterator = $this->getOrderItems()->getIterator();
|
||||
$iterator->uasort(
|
||||
fn (OrderItem $a, OrderItem $b): int => $a->getName() <=> $b->getName()
|
||||
);
|
||||
return new ArrayCollection(
|
||||
iterator_to_array(
|
||||
$iterator
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function addOrderItem(OrderItem $orderItem): static
|
||||
{
|
||||
if (! $this->orderItems->contains($orderItem)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue