116 lines
2.3 KiB
PHP
116 lines
2.3 KiB
PHP
<?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\ProjectRepository")
|
|
*/
|
|
class Project
|
|
{
|
|
/**
|
|
* @ORM\Id()
|
|
* @ORM\GeneratedValue()
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Request", mappedBy="project", orphanRemoval=true)
|
|
*/
|
|
private $request;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity="App\Entity\User", inversedBy="projects")
|
|
*/
|
|
private $users;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=255)
|
|
*/
|
|
private $name;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->request = new ArrayCollection();
|
|
$this->users = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|Request[]
|
|
*/
|
|
public function getRequest(): Collection
|
|
{
|
|
return $this->request;
|
|
}
|
|
|
|
public function addRequest(Request $request): self
|
|
{
|
|
if (!$this->request->contains($request)) {
|
|
$this->request[] = $request;
|
|
$request->setProject($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeRequest(Request $request): self
|
|
{
|
|
if ($this->request->contains($request)) {
|
|
$this->request->removeElement($request);
|
|
// set the owning side to null (unless already changed)
|
|
if ($request->getProject() === $this) {
|
|
$request->setProject(null);
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeUser(User $user): self
|
|
{
|
|
if ($this->users->contains($user)) {
|
|
$this->users->removeElement($user);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): self
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
}
|