155 lines
3.1 KiB
PHP
155 lines
3.1 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\RequestRepository")
|
|
*/
|
|
class Request
|
|
{
|
|
/**
|
|
* @ORM\Id()
|
|
* @ORM\GeneratedValue()
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=255)
|
|
*/
|
|
private $title;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="requests")
|
|
* @ORM\JoinColumn(nullable=false)
|
|
*/
|
|
private $author;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
private $createdAt;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Project", inversedBy="request")
|
|
* @ORM\JoinColumn(nullable=false)
|
|
*/
|
|
private $project;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="request", orphanRemoval=true)
|
|
*/
|
|
private $comments;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\RequestStatus", inversedBy="requests")
|
|
* @ORM\JoinColumn(nullable=true)
|
|
*/
|
|
private $status;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->comments = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getTitle(): ?string
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
public function setTitle(string $title): self
|
|
{
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAuthor(): ?User
|
|
{
|
|
return $this->author;
|
|
}
|
|
|
|
public function setAuthor(?User $author): self
|
|
{
|
|
$this->author = $author;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): ?\DateTimeInterface
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
|
{
|
|
$this->createdAt = $createdAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getProject(): ?Project
|
|
{
|
|
return $this->project;
|
|
}
|
|
|
|
public function setProject(?Project $project): self
|
|
{
|
|
$this->project = $project;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|Comment[]
|
|
*/
|
|
public function getComments(): Collection
|
|
{
|
|
return $this->comments;
|
|
}
|
|
|
|
public function addComment(Comment $comment): self
|
|
{
|
|
if (!$this->comments->contains($comment)) {
|
|
$this->comments[] = $comment;
|
|
$comment->setRequest($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeComment(Comment $comment): self
|
|
{
|
|
if ($this->comments->contains($comment)) {
|
|
$this->comments->removeElement($comment);
|
|
// set the owning side to null (unless already changed)
|
|
if ($comment->getRequest() === $this) {
|
|
$comment->setRequest(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStatus(): ?RequestStatus
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function setStatus(?RequestStatus $status): self
|
|
{
|
|
$this->status = $status;
|
|
|
|
return $this;
|
|
}
|
|
}
|