src/Entity/Profile.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\ProfileRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassProfileRepository::class)]
  9. #[ApiResource]
  10. class Profile
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length50)]
  17.     private ?string $profileName null;
  18.     #[ORM\OneToMany(mappedBy'profile'targetEntityUsers::class, orphanRemovaltrue)]
  19.     private Collection $users;
  20.     #[ORM\OneToMany(mappedBy'profile'targetEntityProfileMenu::class, orphanRemovaltrue)]
  21.     private Collection $profileMenus;
  22.     public function __construct()
  23.     {
  24.         $this->users = new ArrayCollection();
  25.         $this->profileMenus = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getProfileName(): ?string
  32.     {
  33.         return $this->profileName;
  34.     }
  35.     public function setProfileName(string $profileName): self
  36.     {
  37.         $this->profileName $profileName;
  38.         return $this;
  39.     }
  40.     /**
  41.      * @return Collection<int, Users>
  42.      */
  43.     public function getUsers(): Collection
  44.     {
  45.         return $this->users;
  46.     }
  47.     public function addUser(Users $user): self
  48.     {
  49.         if (!$this->users->contains($user)) {
  50.             $this->users->add($user);
  51.             $user->setProfile($this);
  52.         }
  53.         return $this;
  54.     }
  55.     public function removeUser(Users $user): self
  56.     {
  57.         if ($this->users->removeElement($user)) {
  58.             // set the owning side to null (unless already changed)
  59.             if ($user->getProfile() === $this) {
  60.                 $user->setProfile(null);
  61.             }
  62.         }
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, ProfileMenu>
  67.      */
  68.     public function getProfileMenus(): Collection
  69.     {
  70.         return $this->profileMenus;
  71.     }
  72.     public function addProfileMenu(ProfileMenu $profileMenu): self
  73.     {
  74.         if (!$this->profileMenus->contains($profileMenu)) {
  75.             $this->profileMenus->add($profileMenu);
  76.             $profileMenu->setProfile($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeProfileMenu(ProfileMenu $profileMenu): self
  81.     {
  82.         if ($this->profileMenus->removeElement($profileMenu)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($profileMenu->getProfile() === $this) {
  85.                 $profileMenu->setProfile(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90. }