<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserGroupRepository")
*/
class UserGroup
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(nullable=false)
*/
private $registeredBy;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
*/
private $updatedBy;
/**
* @ORM\Column(type="boolean")
*/
private $isActive;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\User", mappedBy="userGroup")
*/
private $users;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Permission", inversedBy="userGroups")
*/
private $permission;
public function __construct()
{
$this->users = new ArrayCollection();
$this->permission = 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;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getRegisteredBy(): ?User
{
return $this->registeredBy;
}
public function setRegisteredBy(?User $registeredBy): self
{
$this->registeredBy = $registeredBy;
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setUpdatedBy(?User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addUserGroup($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
$user->removeUserGroup($this);
}
return $this;
}
/**
* @return Collection|Permission[]
*/
public function getPermission(): Collection
{
return $this->permission;
}
public function addPermission(Permission $permission): self
{
if (!$this->permission->contains($permission)) {
$this->permission[] = $permission;
}
return $this;
}
public function removePermission(Permission $permission): self
{
if ($this->permission->contains($permission)) {
$this->permission->removeElement($permission);
}
return $this;
}
}