WIP: Implement teamer document upload handling
This commit is contained in:
+37
-17
@@ -5,6 +5,8 @@ namespace App\Entity;
|
||||
use App\Entity\Traits\BlameableEntity;
|
||||
use App\Entity\Traits\TimestampableEntity;
|
||||
use App\Repository\DispositionRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
@@ -16,8 +18,11 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
|
||||
use TimestampableEntity;
|
||||
|
||||
public const STATUS_NEW = 'new';
|
||||
public const STATUS_PENDING = 'pending';
|
||||
public const STATUS_CHECKING_CONTRACT = 'checking_contract';
|
||||
public const STATUS_CONFIRMED = 'confirmed';
|
||||
public const STATUS_CHECKING_INVOICE = 'checking_invoice';
|
||||
public const STATUS_PAID = 'paid';
|
||||
public const STATUS_COMPLETED = 'completed';
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
@@ -39,11 +44,8 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $remarks;
|
||||
|
||||
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
|
||||
private ?Upload $contractPdf = null;
|
||||
|
||||
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
|
||||
private ?Upload $invoicePdf = null;
|
||||
#[ORM\OneToMany(mappedBy: 'disposition', targetEntity: Upload::class, cascade: ['persist', 'remove'])]
|
||||
private Collection $documents;
|
||||
|
||||
public function __construct(Application $application)
|
||||
{
|
||||
@@ -52,6 +54,7 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
|
||||
$this->assignment = $application->getAssignment();
|
||||
$this->teamer = $application->getTeamer();
|
||||
$this->remarks = $application->getRemarks();
|
||||
$this->documents = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -112,26 +115,43 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContractPdf(): ?Upload
|
||||
/**
|
||||
* @return Collection<int, Upload>
|
||||
*/
|
||||
public function getDocuments(): Collection
|
||||
{
|
||||
return $this->contractPdf;
|
||||
return $this->documents;
|
||||
}
|
||||
|
||||
public function setContractPdf(?Upload $contractPdf): static
|
||||
public function getDocumentByType(string $type): ?Upload
|
||||
{
|
||||
$this->contractPdf = $contractPdf;
|
||||
foreach ($this->getDocuments() as $upload) {
|
||||
if ($type === $upload->getType()) {
|
||||
return $upload;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addDocument(Upload $document): static
|
||||
{
|
||||
if (!$this->documents->contains($document)) {
|
||||
$this->documents->add($document);
|
||||
$document->setDisposition($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getInvoicePdf(): ?Upload
|
||||
public function removeDocument(Upload $document): static
|
||||
{
|
||||
return $this->invoicePdf;
|
||||
}
|
||||
|
||||
public function setInvoicePdf(?Upload $invoicePdf): static
|
||||
{
|
||||
$this->invoicePdf = $invoicePdf;
|
||||
if ($this->documents->removeElement($document)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($document->getDisposition() === $this) {
|
||||
$document->setDisposition(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user