<?phpnamespace Roothirsch\CoreBundle\Entity;use ApiPlatform\Core\Annotation\ApiResource;use Roothirsch\CoreBundle\Entity\Traits\TimetrackedTrait;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * Role. * * @ORM\Entity(repositoryClass="Roothirsch\CoreBundle\Repository\GroupRepository") * @ORM\Table(name="groups") * @ApiResource */class Group{ use TimetrackedTrait; /** * @var integer * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=191, unique=true) */ private $name; /** * @ORM\Column(type="string", length=255) */ private $title; /** * @var bool * * @ORM\Column(name="active", type="boolean") */ private $active = true; /** * @ORM\Column(type="string", length=255) */ private $type; /** * @ORM\ManyToMany(targetEntity=User::class, mappedBy="groups") */ private $users; /** * @ORM\ManyToMany(targetEntity=Company::class, mappedBy="groups") */ private $companies; public function __construct() { $this->users = new ArrayCollection(); $this->companies = new ArrayCollection(); } public function __toString() { return $this->title; } /** * Get id. * * @return string */ public function getId() { return $this->id; } /** * Set name. * * @param string $name * * @return Group */ public function setName($name) { $this->name = $name; return $this; } /** * Get name. * * @return string */ public function getName() { return $this->name; } /** * Set active. * * @param bool $active * * @return Group */ public function setActive($active) { $this->active = $active; return $this; } /** * Get active. * * @return bool */ public function getActive() { return $this->active; } public function getType(): ?string { return $this->type; } public function setType(string $type): self { $this->type = $type; 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->addRole($this); } return $this; } public function removeUser(User $user): self { if ($this->users->removeElement($user)) { $user->removeRole($this); } return $this; } public function getTitle(): ?string { return $this->title; } public function setTitle(string $title): self { $this->title = $title; return $this; } /** * @return Collection|Company[] */ public function getCompanies(): Collection { return $this->companies; } public function addCompany(Company $company): self { if (!$this->companies->contains($company)) { $this->companies[] = $company; $company->addGroup($this); } return $this; } public function removeCompany(Company $company): self { if ($this->companies->removeElement($company)) { $company->removeGroup($this); } return $this; }}