<?php
namespace App\Entity\Shop\Menu;
use App\Entity\BaseEntity;
use App\Entity\Shop\Shop\Shop;
use App\Repository\Shop\Menu\MenuRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Entity(repositoryClass: MenuRepository::class)]
class Menu extends BaseEntity
{
#[ORM\Id]
#[ORM\Column(type: 'guid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private ?string $id;
#[ORM\ManyToOne(inversedBy: 'menus')]
#[ORM\JoinColumn(nullable: false)]
private ?Shop $shop = null;
#[ORM\Column(length: 255)]
private ?string $position = null;
#[ORM\OneToMany(mappedBy: 'menu', targetEntity: MenuItem::class)]
private Collection $menuItems;
#[ORM\Column(length: 255, nullable: true)]
private ?string $title = null;
public function __construct()
{
parent::__construct();
$this->menuItems = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getShop(): ?Shop
{
return $this->shop;
}
public function setShop(?Shop $shop): static
{
$this->shop = $shop;
return $this;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(string $position): static
{
$this->position = $position;
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->setMenu($this);
}
return $this;
}
public function removeMenuItem(MenuItem $menuItem): static
{
if ($this->menuItems->removeElement($menuItem)) {
// set the owning side to null (unless already changed)
if ($menuItem->getMenu() === $this) {
$menuItem->setMenu(null);
}
}
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): static
{
$this->title = $title;
return $this;
}
}