WIP: Implement model
This commit is contained in:
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\BlameableEntity;
|
||||
use App\Entity\Traits\TimestampableEntity;
|
||||
use App\Repository\AssignmentRepository;
|
||||
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;
|
||||
|
||||
#[ORM\Entity(repositoryClass: AssignmentRepository::class)]
|
||||
class Assignment implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
{
|
||||
use BlameableEntity;
|
||||
use TimestampableEntity;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 36, unique: true)]
|
||||
private string $uuid;
|
||||
|
||||
#[ORM\Column(length: 64)]
|
||||
private ?string $busProCode = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $available = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $dateFrom = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $dateTo = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $benefits = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $remarks = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?User $owner = null;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Pickup::class)]
|
||||
private Collection $pickups;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Fee::class)]
|
||||
private Collection $fees;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'assignment', targetEntity: Application::class)]
|
||||
private Collection $applications;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'assignment', targetEntity: Disposition::class)]
|
||||
private Collection $dispositions;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'assignment', targetEntity: DispositionRequirement::class)]
|
||||
private Collection $requirements;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->uuid = Uuid::v4();
|
||||
$this->pickups = new ArrayCollection();
|
||||
$this->fees = new ArrayCollection();
|
||||
$this->applications = new ArrayCollection();
|
||||
$this->dispositions = new ArrayCollection();
|
||||
$this->requirements = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUuid(): string
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
public function getBusProCode(): ?string
|
||||
{
|
||||
return $this->busProCode;
|
||||
}
|
||||
|
||||
public function setBusProCode(string $busProCode): static
|
||||
{
|
||||
$this->busProCode = $busProCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAvailable(): ?int
|
||||
{
|
||||
return $this->available;
|
||||
}
|
||||
|
||||
public function setAvailable(int $available): static
|
||||
{
|
||||
$this->available = $available;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateFrom(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateFrom;
|
||||
}
|
||||
|
||||
public function setDateFrom(\DateTimeImmutable $dateFrom): static
|
||||
{
|
||||
$this->dateFrom = $dateFrom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateTo(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateTo;
|
||||
}
|
||||
|
||||
public function setDateTo(\DateTimeImmutable $dateTo): static
|
||||
{
|
||||
$this->dateTo = $dateTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBenefits(): ?string
|
||||
{
|
||||
return $this->benefits;
|
||||
}
|
||||
|
||||
public function setBenefits(string $benefits): static
|
||||
{
|
||||
$this->benefits = $benefits;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRemarks(): ?string
|
||||
{
|
||||
return $this->remarks;
|
||||
}
|
||||
|
||||
public function setRemarks(?string $remarks): static
|
||||
{
|
||||
$this->remarks = $remarks;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOwner(): ?User
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function setOwner(?User $owner): static
|
||||
{
|
||||
$this->owner = $owner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Pickup>
|
||||
*/
|
||||
public function getPickups(): Collection
|
||||
{
|
||||
return $this->pickups;
|
||||
}
|
||||
|
||||
public function addPickup(Pickup $pickup): static
|
||||
{
|
||||
if (!$this->pickups->contains($pickup)) {
|
||||
$this->pickups->add($pickup);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePickup(Pickup $pickup): static
|
||||
{
|
||||
$this->pickups->removeElement($pickup);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Fee>
|
||||
*/
|
||||
public function getFees(): Collection
|
||||
{
|
||||
return $this->fees;
|
||||
}
|
||||
|
||||
public function addFee(Fee $fee): static
|
||||
{
|
||||
if (!$this->fees->contains($fee)) {
|
||||
$this->fees->add($fee);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeFee(Fee $fee): static
|
||||
{
|
||||
$this->fees->removeElement($fee);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Application>
|
||||
*/
|
||||
public function getApplications(): Collection
|
||||
{
|
||||
return $this->applications;
|
||||
}
|
||||
|
||||
public function addApplication(Application $application): static
|
||||
{
|
||||
if (!$this->applications->contains($application)) {
|
||||
$this->applications->add($application);
|
||||
$application->setAssignment($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeApplication(Application $application): static
|
||||
{
|
||||
if ($this->applications->removeElement($application)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($application->getAssignment() === $this) {
|
||||
$application->setAssignment(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Disposition>
|
||||
*/
|
||||
public function getDispositions(): Collection
|
||||
{
|
||||
return $this->dispositions;
|
||||
}
|
||||
|
||||
public function addDisposition(Disposition $disposition): static
|
||||
{
|
||||
if (!$this->dispositions->contains($disposition)) {
|
||||
$this->dispositions->add($disposition);
|
||||
$disposition->setAssignment($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeDisposition(Disposition $disposition): static
|
||||
{
|
||||
if ($this->dispositions->removeElement($disposition)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($disposition->getAssignment() === $this) {
|
||||
$disposition->setAssignment(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, DispositionRequirement>
|
||||
*/
|
||||
public function getRequirements(): Collection
|
||||
{
|
||||
return $this->requirements;
|
||||
}
|
||||
|
||||
public function addRequirement(DispositionRequirement $requirement): static
|
||||
{
|
||||
if (!$this->requirements->contains($requirement)) {
|
||||
$this->requirements->add($requirement);
|
||||
$requirement->setAssignment($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeRequirement(DispositionRequirement $requirement): static
|
||||
{
|
||||
if ($this->requirements->removeElement($requirement)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($requirement->getAssignment() === $this) {
|
||||
$requirement->setAssignment(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user