add itemextras to to orderitem

This commit is contained in:
lubiana 2024-02-13 21:50:10 +01:00
parent 53009471e1
commit 1dab51005a
2 changed files with 94 additions and 0 deletions

View file

@ -27,6 +27,9 @@ class OrderItem
#[ORM\JoinColumn(nullable: false)]
private ?MenuItem $menuItem = null;
#[ORM\ManyToMany(targetEntity: ItemExtra::class)]
private Collection $extras;
public function __construct()
{
$this->id = new Ulid;
@ -61,4 +64,28 @@ class OrderItem
return $this;
}
/**
* @return Collection<int, ItemExtra>
*/
public function getExtras(): Collection
{
return $this->extras;
}
public function addExtra(ItemExtra $extra): static
{
if (!$this->extras->contains($extra)) {
$this->extras->add($extra);
}
return $this;
}
public function removeExtra(ItemExtra $extra): static
{
$this->extras->removeElement($extra);
return $this;
}
}