src/Entity/Role.php line 13
<?phpnamespace App\Entity;use App\Entity\Permission;use Doctrine\ORM\Mapping as ORM;use App\Repository\RoleRepository;use Doctrine\Common\Collections\Collection;use Doctrine\Common\Collections\ArrayCollection;use Gedmo\Mapping\Annotation as Gedmo;#[ORM\Entity(repositoryClass: RoleRepository::class)]class Role{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column()]private ?int $id = null;#[ORM\Column]#[Gedmo\Timestampable(on: 'create')]private ?\DateTimeImmutable $createdAt = null;#[ORM\Column(length: 255)]private ?string $title = null;#[ORM\Column(length: 255)]private ?string $label = null;#[ORM\Column(nullable: true)]private ?int $authorId = null;#[ORM\ManyToMany(mappedBy: 'roles', targetEntity: Permission::class)]private Collection $permissions;#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'accessRoles')]private Collection $users;public function __construct(){$this->permissions = new ArrayCollection();$this->users = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getCreatedAt(): ?\DateTimeImmutable{return $this->createdAt;}public function setCreatedAt(\DateTimeImmutable $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getTitle(): ?string{return $this->title;}public function setTitle(string $title): self{$this->title = $title;return $this;}public function getLabel(): ?string{return $this->label;}public function setLabel(string $label): self{$this->label = $label;return $this;}public function getAuthorId(): ?int{return $this->authorId;}public function setAuthorId(?int $authorId): self{$this->authorId = $authorId;return $this;}public function setUsers(?User $users): self{$this->users = $users;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;}/*** @return Collection<int, Permission>*/public function getPermissions(): Collection{return $this->permissions;}public function addPermission(Permission $permission): self{if (!$this->permissions->contains($permission)) {$this->permissions->add($permission);$permission->addRole($this);}return $this;}public function removePermission(Permission $permission): self{if ($this->permissions->removeElement($permission)) {$permission->removeRole($this);}return $this;}}