src/Entity/Role.php line 18
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\RoleRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: RoleRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
)]
class Role
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(["write"])]
private ?int $id = null;
#[Groups(["write","read"])]
#[ORM\Column(length: 255)]
private ?string $name = null;
#[Groups(["write","read"])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'storedRoles')]
private Collection $users;
#[ORM\Column(nullable: true)]
private ?int $nbrUsers = null;
#[ORM\Column(nullable: true)]
private ?int $nbrStores = null;
#[ORM\Column(nullable: true)]
private ?int $nbrVendors = null;
#[ORM\Column(nullable: true)]
private ?int $nbrRecords = null;
#[ORM\Column(nullable: true)]
private ?int $nbrApps = null;
#[Groups(["write","read"])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $code = null;
public function __toString()
{
return (string)$this->name;
}
public function __construct()
{
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users->add($user);
}
return $this;
}
public function removeUser(User $user): self
{
$this->users->removeElement($user);
return $this;
}
public function getNbrUsers(): ?int
{
return $this->nbrUsers;
}
public function setNbrUsers(?int $nbrUsers): static
{
$this->nbrUsers = $nbrUsers;
return $this;
}
public function getNbrStores(): ?int
{
return $this->nbrStores;
}
public function setNbrStores(?int $nbrStores): static
{
$this->nbrStores = $nbrStores;
return $this;
}
public function getNbrVendors(): ?int
{
return $this->nbrVendors;
}
public function setNbrVendors(?int $nbrVendors): static
{
$this->nbrVendors = $nbrVendors;
return $this;
}
public function getNbrRecords(): ?int
{
return $this->nbrRecords;
}
public function setNbrRecords(?int $nbrRecords): static
{
$this->nbrRecords = $nbrRecords;
return $this;
}
public function getNbrApps(): ?int
{
return $this->nbrApps;
}
public function setNbrApps(?int $nbrApps): static
{
$this->nbrApps = $nbrApps;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): static
{
$this->code = $code;
return $this;
}
}