add itemextras to to orderitem
This commit is contained in:
parent
53009471e1
commit
1dab51005a
2 changed files with 94 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue