src/Entity/Shop/Menu/Menu.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Menu;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Shop\Shop\Shop;
  5. use App\Repository\Shop\Menu\MenuRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  10. #[ORM\Entity(repositoryClassMenuRepository::class)]
  11. class Menu extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'guid'uniquetrue)]
  15.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  16.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  17.     private ?string $id;
  18.     #[ORM\ManyToOne(inversedBy'menus')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     private ?Shop $shop null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $position null;
  23.     #[ORM\OneToMany(mappedBy'menu'targetEntityMenuItem::class)]
  24.     private Collection $menuItems;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $title null;
  27.     public function __construct()
  28.     {
  29.         parent::__construct();
  30.         $this->menuItems = new ArrayCollection();
  31.     }
  32.     public function getId(): ?string
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getShop(): ?Shop
  37.     {
  38.         return $this->shop;
  39.     }
  40.     public function setShop(?Shop $shop): static
  41.     {
  42.         $this->shop $shop;
  43.         return $this;
  44.     }
  45.     public function getPosition(): ?string
  46.     {
  47.         return $this->position;
  48.     }
  49.     public function setPosition(string $position): static
  50.     {
  51.         $this->position $position;
  52.         return $this;
  53.     }
  54.     /**
  55.      * @return Collection<int, MenuItem>
  56.      */
  57.     public function getMenuItems(): Collection
  58.     {
  59.         return $this->menuItems;
  60.     }
  61.     public function addMenuItem(MenuItem $menuItem): static
  62.     {
  63.         if (!$this->menuItems->contains($menuItem)) {
  64.             $this->menuItems->add($menuItem);
  65.             $menuItem->setMenu($this);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeMenuItem(MenuItem $menuItem): static
  70.     {
  71.         if ($this->menuItems->removeElement($menuItem)) {
  72.             // set the owning side to null (unless already changed)
  73.             if ($menuItem->getMenu() === $this) {
  74.                 $menuItem->setMenu(null);
  75.             }
  76.         }
  77.         return $this;
  78.     }
  79.     public function getTitle(): ?string
  80.     {
  81.         return $this->title;
  82.     }
  83.     public function setTitle(?string $title): static
  84.     {
  85.         $this->title $title;
  86.         return $this;
  87.     }
  88. }