src/Entity/Roles.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RolesRepository;
  4. use App\Traits\CommonTrt;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=RolesRepository::class)
  10.  */
  11. class Roles
  12. {
  13.     use CommonTrt;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\Column(type="text")
  26.      */
  27.     private $description;
  28.     /**
  29.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="userRoles")
  30.      */
  31.     private $users;
  32.     public function __construct()
  33.     {
  34.         $this->users = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getName(): ?string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function setName(string $name): self
  45.     {
  46.         $this->name = $name;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, User>
  51.      */
  52.     public function getUsers(): Collection
  53.     {
  54.         return $this->users;
  55.     }
  56.     public function addUser(User $user): self
  57.     {
  58.         if (!$this->users->contains($user)) {
  59.             $this->users[] = $user;
  60.             $user->addUserRole($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeUser(User $user): self
  65.     {
  66.         if ($this->users->removeElement($user)) {
  67.             $user->removeUserRole($this);
  68.         }
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return mixed
  73.      */
  74.     public function getDescription()
  75.     {
  76.         return $this->description;
  77.     }
  78.     /**
  79.      * @param mixed $description
  80.      */
  81.     public function setDescription($description): void
  82.     {
  83.         $this->description = $description;
  84.     }
  85. }