<?php
namespace App\Entity\System;
use App\Repository\System\rolesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: rolesRepository::class)]
class roles
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string',length: 255, nullable: true)]
private $name;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\Column(type: 'datetime', nullable: true)]
private $created_at;
#[ORM\Column(type: 'datetime', nullable: true)]
private $updated_at;
#[ORM\OneToMany(mappedBy: 'roles', targetEntity: permissions::class)]
private $permissions;
#[ORM\OneToMany(mappedBy: 'roles', targetEntity: access::class)]
private $accesses;
#[ORM\OneToMany(mappedBy: 'roles', targetEntity: usersRoles::class)]
private $usersRoles;
public function __construct()
{
$this->permissions = new ArrayCollection();
$this->accesses = new ArrayCollection();
$this->usersRoles = new ArrayCollection();
}
public function setId(?int $id): self
{
$this->id = $id;
return $this;
}
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;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @return Collection<int, permissions>
*/
public function getPermissions(): Collection
{
return $this->permissions;
}
public function addPermission(permissions $permission): self
{
if (!$this->permissions->contains($permission)) {
$this->permissions[] = $permission;
$permission->setRolesId($this);
}
return $this;
}
public function removePermission(permissions $permission): self
{
if ($this->permissions->removeElement($permission)) {
// set the owning side to null (unless already changed)
if ($permission->getRolesId() === $this) {
$permission->setRolesId(null);
}
}
return $this;
}
/**
* @return Collection<int, access>
*/
public function getAccesses(): Collection
{
return $this->accesses;
}
public function addAccess(access $access): self
{
if (!$this->accesses->contains($access)) {
$this->accesses[] = $access;
$access->setRolesId($this);
}
return $this;
}
public function removeAccess(access $access): self
{
if ($this->accesses->removeElement($access)) {
// set the owning side to null (unless already changed)
if ($access->getRolesId() === $this) {
$access->setRolesId(null);
}
}
return $this;
}
/**
* @return Collection<int, usersRoles>
*/
public function getUsersRoles(): Collection
{
return $this->usersRoles;
}
public function addUsersRole(usersRoles $usersRole): self
{
if (!$this->usersRoles->contains($usersRole)) {
$this->usersRoles[] = $usersRole;
$usersRole->setRolesId($this);
}
return $this;
}
public function removeUsersRole(usersRoles $usersRole): self
{
if ($this->usersRoles->removeElement($usersRole)) {
// set the owning side to null (unless already changed)
if ($usersRole->getRolesId() === $this) {
$usersRole->setRolesId(null);
}
}
return $this;
}
}