add option to select previous menuitems
All checks were successful
/ ls (pull_request) Successful in 33s
/ ls (push) Successful in 29s

This commit is contained in:
lubiana 2024-06-26 20:12:27 +02:00
parent 57b4e33028
commit 45029e0a4c
No known key found for this signature in database
11 changed files with 410 additions and 94 deletions

View file

@ -28,9 +28,16 @@ class FoodVendor
#[ORM\OneToMany(targetEntity: FoodOrder::class, mappedBy: 'foodVendor', orphanRemoval: true)]
private Collection $foodOrders;
/**
* @var Collection<int, MenuItem>
*/
#[ORM\OneToMany(targetEntity: MenuItem::class, mappedBy: 'foodVendor', orphanRemoval: true)]
private Collection $menuItems;
public function __construct()
{
$this->foodOrders = new ArrayCollection;
$this->menuItems = new ArrayCollection;
}
public function getId(): Ulid|null
@ -77,4 +84,32 @@ class FoodVendor
return $this;
}
/**
* @return Collection<int, MenuItem>
*/
public function getMenuItems(): Collection
{
return $this->menuItems;
}
public function addMenuItem(MenuItem $menuItem): static
{
if (! $this->menuItems->contains($menuItem)) {
$this->menuItems->add($menuItem);
$menuItem->setFoodVendor($this);
}
return $this;
}
public function removeMenuItem(MenuItem $menuItem): static
{
// set the owning side to null (unless already changed)
if ($this->menuItems->removeElement($menuItem) && $menuItem->getFoodVendor() === $this) {
$menuItem->setFoodVendor(null);
}
return $this;
}
}