<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserGroupRepository")
*/
class UserGroup
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180)
* @Assert\NotBlank(message="Please provide group name")
*/
private $groupName;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $additionalInfo;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Workspace", inversedBy="userGroup")
*/
private $workspace;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $createdBy;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\User", mappedBy="userGroups")
*/
private $users;
/**
* @ORM\Column(type="array", nullable=true)
*/
private $permission;
public function __toString()
{
return $this->groupName;
}
public function __construct()
{
$this->users = new ArrayCollection();
//$this->permission = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getGroupName(): ?string
{
return $this->groupName;
}
public function setGroupName(string $groupName): self
{
$this->groupName = $groupName;
return $this;
}
public function getAdditionalInfo(): ?string
{
return $this->additionalInfo;
}
public function setAdditionalInfo(string $additionalInfo): self
{
$this->additionalInfo = $additionalInfo;
return $this;
}
public function getCreatedBy(): ?int
{
return $this->createdBy;
}
public function setCreatedBy(?int $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getWorkspace(): ?Workspace
{
return $this->workspace;
}
public function setWorkspace(?Workspace $workspace): self
{
$this->workspace = $workspace;
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;
}
public function getPermission(): ?array
{
return $this->permission;
}
public function setPermission(?array $permission): self
{
$this->permission = $permission;
return $this;
}
}