<?php
namespace App\Entity;
use App\Repository\RightRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=RightRepository::class)
* @ORM\Table(name="`right`")
*/
class Right
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $code;
/**
* @ORM\ManyToMany(targetEntity=GroupUser::class, inversedBy="rights")
*/
private $groups;
public function __construct()
{
$this->groups = 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 getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
/**
* @return Collection|GroupUser[]
*/
public function getGroups(): Collection
{
return $this->groups;
}
public function addGroup(GroupUser $group): self
{
if (!$this->groups->contains($group)) {
$this->groups[] = $group;
}
return $this;
}
public function removeGroup(GroupUser $group): self
{
$this->groups->removeElement($group);
return $this;
}
}