src/Entity/Roles.php line 11

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use Doctrine\ORM\Mapping as ORM;
  5. #[ORM\Entity]
  6. #[ORM\Table(name'roles')]
  7. class Roles
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private $id;
  13.     #[ORM\Column(name'name'type'string'length30)]
  14.     private $name;
  15.     #[ORM\Column(name'role'type'string'length20uniquetrue)]
  16.     private $role;
  17.     #[ORM\OneToMany(targetEntity'Admin'mappedBy'role')]
  18.     private $users;
  19.     /**
  20.      * Constructor.
  21.      */
  22.     public function __construct()
  23.     {
  24.         $this->users = new \Doctrine\Common\Collections\ArrayCollection();
  25.     }
  26.     public function getRole()
  27.     {
  28.         return $this->role;
  29.     }
  30.     public function getId()
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getName()
  35.     {
  36.         return $this->name;
  37.     }
  38.     public function getUsers()
  39.     {
  40.         return $this->users;
  41.     }
  42.     public function setId($id): void
  43.     {
  44.         $this->id $id;
  45.     }
  46.     public function setName($name): void
  47.     {
  48.         $this->name $name;
  49.     }
  50.     public function setUsers($users): void
  51.     {
  52.         $this->users $users;
  53.     }
  54.     public function setRole($role): void
  55.     {
  56.         $this->role $role;
  57.     }
  58.     /**
  59.      * Add users.
  60.      *
  61.      * @return Roles
  62.      */
  63.     public function addAdmin(Admin $admins)
  64.     {
  65.         $this->admins[] = $admins;
  66.         return $this;
  67.     }
  68.     /**
  69.      * Remove users.
  70.      */
  71.     public function removeUser(Admin $admins): void
  72.     {
  73.         $this->admins->removeElement($admins);
  74.     }
  75.     public function __toString(): string
  76.     {
  77.         return $this->name;
  78.     }
  79. }