first commit
This commit is contained in:
159
src/Entity/Project.php
Normal file
159
src/Entity/Project.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ProjectRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ProjectRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_project_title', fields: ['title'])]
|
||||
class Project
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, unique: true)]
|
||||
private ?string $title = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $logo = null;
|
||||
|
||||
#[ORM\Column(type: 'datetime', nullable: true)]
|
||||
private ?\DateTimeInterface $updateAt = null;
|
||||
|
||||
#[ORM\Column(nullable: false)]
|
||||
private array $redmine;
|
||||
|
||||
/**
|
||||
* @var Collection<int, User>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'projects')]
|
||||
private Collection $users;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Issue>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Issue::class, mappedBy: 'project', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy([
|
||||
'rowstatus' => 'ASC',
|
||||
'rowsprint' => 'DESC',
|
||||
'rowversion' => 'DESC',
|
||||
'rowissue' => 'ASC',
|
||||
'id' => 'DESC',
|
||||
])]
|
||||
private Collection $issues;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->users = new ArrayCollection();
|
||||
$this->issues = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(int $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): static
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLogo(): ?string
|
||||
{
|
||||
return $this->logo ? $this->logo : 'medias/logo/logo.png';
|
||||
}
|
||||
|
||||
public function setLogo(?string $logo): static
|
||||
{
|
||||
$this->logo = $logo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdateAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updateAt;
|
||||
}
|
||||
|
||||
public function setUpdateAt(?\DateTimeInterface $updateAt): static
|
||||
{
|
||||
$this->updateAt = $updateAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRedmine(): array
|
||||
{
|
||||
return $this->redmine;
|
||||
}
|
||||
|
||||
public function setRedmine(array $redmine): static
|
||||
{
|
||||
$this->redmine = $redmine;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, User>
|
||||
*/
|
||||
public function getUsers(): Collection
|
||||
{
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
public function addUser(User $user): static
|
||||
{
|
||||
if (!$this->users->contains($user)) {
|
||||
$this->users->add($user);
|
||||
$user->addProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeUser(User $user): static
|
||||
{
|
||||
if ($this->users->removeElement($user)) {
|
||||
$user->removeProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Issue>
|
||||
*/
|
||||
public function getIssues(): Collection
|
||||
{
|
||||
return $this->issues;
|
||||
}
|
||||
|
||||
public function addIssue(Issue $issue): self
|
||||
{
|
||||
if (!$this->issues->contains($issue)) {
|
||||
$this->issues[] = $issue;
|
||||
$issue->setProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user