src/Entity/UserGroup.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use  Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\UserGroupRepository")
  9.  */
  10. class UserGroup
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=180)
  20.      * @Assert\NotBlank(message="Please provide group name")
  21.      */
  22.     private $groupName;
  23.     /**
  24.      * @ORM\Column(type="text", nullable=true)
  25.      */
  26.     private $additionalInfo;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity="App\Entity\Workspace", inversedBy="userGroup")
  29.      */
  30.     private $workspace;
  31.     /**
  32.      * @ORM\Column(type="integer", nullable=true)
  33.      */
  34.     private $createdBy;
  35.     /**
  36.      * @ORM\ManyToMany(targetEntity="App\Entity\User", mappedBy="userGroups")
  37.      */
  38.     private $users;
  39.     /**
  40.      * @ORM\Column(type="array", nullable=true)
  41.      */
  42.     private $permission;
  43.     public function __toString()
  44.     {
  45.         return $this->groupName;
  46.     }
  47.     public function __construct()
  48.     {
  49.         $this->users = new ArrayCollection();
  50.         //$this->permission = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getGroupName(): ?string
  57.     {
  58.         return $this->groupName;
  59.     }
  60.     public function setGroupName(string $groupName): self
  61.     {
  62.         $this->groupName $groupName;
  63.         return $this;
  64.     }
  65.     public function getAdditionalInfo(): ?string
  66.     {
  67.         return $this->additionalInfo;
  68.     }
  69.     public function setAdditionalInfo(string $additionalInfo): self
  70.     {
  71.         $this->additionalInfo $additionalInfo;
  72.         return $this;
  73.     }
  74.     public function getCreatedBy(): ?int
  75.     {
  76.         return $this->createdBy;
  77.     }
  78.     public function setCreatedBy(?int $createdBy): self
  79.     {
  80.         $this->createdBy $createdBy;
  81.         return $this;
  82.     }
  83.     public function getWorkspace(): ?Workspace
  84.     {
  85.         return $this->workspace;
  86.     }
  87.     public function setWorkspace(?Workspace $workspace): self
  88.     {
  89.         $this->workspace $workspace;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection|User[]
  94.      */
  95.     public function getUsers(): Collection
  96.     {
  97.         return $this->users;
  98.     }
  99.     public function addUser(User $user): self
  100.     {
  101.         if (!$this->users->contains($user)) {
  102.             $this->users[] = $user;
  103.             $user->addUserGroup($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeUser(User $user): self
  108.     {
  109.         if ($this->users->contains($user)) {
  110.             $this->users->removeElement($user);
  111.             $user->removeUserGroup($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function getPermission(): ?array
  116.     {
  117.         return $this->permission;
  118.     }
  119.     public function setPermission(?array $permission): self
  120.     {
  121.         $this->permission $permission;
  122.         return $this;
  123.     }
  124. }