src/Entity/Menu.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\MenuRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassMenuRepository::class)]
  9. #[ApiResource]
  10. class Menu
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length70)]
  17.     private ?string $menuName null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $menuLink null;
  20.     #[ORM\ManyToOne(inversedBy'menus')]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?MenuType $menuType null;
  23.     #[ORM\OneToMany(mappedBy'menu'targetEntityProfileMenu::class, orphanRemovaltrue)]
  24.     private Collection $profileMenus;
  25.     public function __construct()
  26.     {
  27.         $this->profileMenus = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getMenuName(): ?string
  34.     {
  35.         return $this->menuName;
  36.     }
  37.     public function setMenuName(string $menuName): self
  38.     {
  39.         $this->menuName $menuName;
  40.         return $this;
  41.     }
  42.     public function getMenuLink(): ?string
  43.     {
  44.         return $this->menuLink;
  45.     }
  46.     public function setMenuLink(string $menuLink): self
  47.     {
  48.         $this->menuLink $menuLink;
  49.         return $this;
  50.     }
  51.     public function getMenuType(): ?MenuType
  52.     {
  53.         return $this->menuType;
  54.     }
  55.     public function setMenuType(?MenuType $menuType): self
  56.     {
  57.         $this->menuType $menuType;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, ProfileMenu>
  62.      */
  63.     public function getProfileMenus(): Collection
  64.     {
  65.         return $this->profileMenus;
  66.     }
  67.     public function addProfileMenu(ProfileMenu $profileMenu): self
  68.     {
  69.         if (!$this->profileMenus->contains($profileMenu)) {
  70.             $this->profileMenus->add($profileMenu);
  71.             $profileMenu->setMenu($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeProfileMenu(ProfileMenu $profileMenu): self
  76.     {
  77.         if ($this->profileMenus->removeElement($profileMenu)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($profileMenu->getMenu() === $this) {
  80.                 $profileMenu->setMenu(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85. }