src/Entity/Role.php line 18

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\RoleRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClassRoleRepository::class)]
  11. #[ApiResource(
  12.     normalizationContext: ['groups' => ['read']],
  13.     denormalizationContext: ['groups' => ['write']],
  14. )]
  15. class Role
  16. {
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     #[Groups(["write"])]
  21.     private ?int $id null;
  22.     #[Groups(["write","read"])]
  23.     #[ORM\Column(length255)]
  24.     private ?string $name null;
  25.     #[Groups(["write","read"])]
  26.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  27.     private ?string $description null;
  28.     #[ORM\ManyToMany(targetEntityUser::class, mappedBy'storedRoles')]
  29.     private Collection $users;
  30.     #[ORM\Column(nullabletrue)]
  31.     private ?int $nbrUsers null;
  32.     #[ORM\Column(nullabletrue)]
  33.     private ?int $nbrStores null;
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?int $nbrVendors null;
  36.     #[ORM\Column(nullabletrue)]
  37.     private ?int $nbrRecords null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?int $nbrApps null;
  40.     #[Groups(["write","read"])]
  41.     #[ORM\Column(length255nullabletrue)]
  42.     private ?string $code null;
  43.     public function __toString()
  44.     {
  45.         return (string)$this->name;
  46.     }
  47.     public function __construct()
  48.     {
  49.         $this->users = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getDescription(): ?string
  65.     {
  66.         return $this->description;
  67.     }
  68.     public function setDescription(?string $description): self
  69.     {
  70.         $this->description $description;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, User>
  75.      */
  76.     public function getUsers(): Collection
  77.     {
  78.         return $this->users;
  79.     }
  80.     public function addUser(User $user): self
  81.     {
  82.         if (!$this->users->contains($user)) {
  83.             $this->users->add($user);
  84.         }
  85.         return $this;
  86.     }
  87.     public function removeUser(User $user): self
  88.     {
  89.         $this->users->removeElement($user);
  90.         return $this;
  91.     }
  92.     public function getNbrUsers(): ?int
  93.     {
  94.         return $this->nbrUsers;
  95.     }
  96.     public function setNbrUsers(?int $nbrUsers): static
  97.     {
  98.         $this->nbrUsers $nbrUsers;
  99.         return $this;
  100.     }
  101.     public function getNbrStores(): ?int
  102.     {
  103.         return $this->nbrStores;
  104.     }
  105.     public function setNbrStores(?int $nbrStores): static
  106.     {
  107.         $this->nbrStores $nbrStores;
  108.         return $this;
  109.     }
  110.     public function getNbrVendors(): ?int
  111.     {
  112.         return $this->nbrVendors;
  113.     }
  114.     public function setNbrVendors(?int $nbrVendors): static
  115.     {
  116.         $this->nbrVendors $nbrVendors;
  117.         return $this;
  118.     }
  119.     public function getNbrRecords(): ?int
  120.     {
  121.         return $this->nbrRecords;
  122.     }
  123.     public function setNbrRecords(?int $nbrRecords): static
  124.     {
  125.         $this->nbrRecords $nbrRecords;
  126.         return $this;
  127.     }
  128.     public function getNbrApps(): ?int
  129.     {
  130.         return $this->nbrApps;
  131.     }
  132.     public function setNbrApps(?int $nbrApps): static
  133.     {
  134.         $this->nbrApps $nbrApps;
  135.         return $this;
  136.     }
  137.     public function getCode(): ?string
  138.     {
  139.         return $this->code;
  140.     }
  141.     public function setCode(?string $code): static
  142.     {
  143.         $this->code $code;
  144.         return $this;
  145.     }
  146. }