WIP: Implementation of stuff goes on
This commit is contained in:
+26
-49
@@ -4,12 +4,14 @@ namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\BlameableEntity;
|
||||
use App\Entity\Traits\TimestampableEntity;
|
||||
use App\Model\BenefitsDto;
|
||||
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;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ORM\Entity(repositoryClass: AssignmentRepository::class)]
|
||||
class Assignment implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
@@ -26,36 +28,41 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
private string $uuid;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Assert\NotNull(message: 'Bitte gib die Destination an')]
|
||||
private ?int $destinationBusProId = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[Assert\NotNull(message: 'Bitte gib das Jobprofil an')]
|
||||
private ?JobProfile $jobProfile = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $available = null;
|
||||
#[Assert\Range(min: 1, minMessage: 'Die Mindestanzahl ist 1')]
|
||||
private ?int $available = 1;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
#[Assert\NotNull(message: 'Bitte gib das Beginndatum an')]
|
||||
private ?\DateTimeImmutable $dateFrom = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
#[Assert\NotNull(message: 'Bitte gib das Enddatum an')]
|
||||
#[Assert\GreaterThan(propertyPath: 'dateFrom', message: 'Das Enddatum muss nach dem Beginndatum liegen')]
|
||||
private ?\DateTimeImmutable $dateTo = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
#[Assert\GreaterThanOrEqual(propertyPath: 'dateFrom', message: 'Die Busabfahrt muss am oder nach dem Beginndatum liegen')]
|
||||
private ?\DateTimeImmutable $pickupDate = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $pickup = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $benefits = null;
|
||||
#[ORM\Column]
|
||||
private array $benefits;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $remarks = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?User $owner = null;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Fee::class)]
|
||||
#[Assert\Count(min: 1, minMessage: 'Bitte triff mindestens eine Auswahl')]
|
||||
private Collection $fees;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'assignment', targetEntity: Application::class)]
|
||||
@@ -64,8 +71,8 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
#[ORM\OneToMany(mappedBy: 'assignment', targetEntity: Disposition::class)]
|
||||
private Collection $dispositions;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'assignment', targetEntity: DispositionRequirement::class)]
|
||||
private Collection $requirements;
|
||||
#[ORM\ManyToOne]
|
||||
private ?User $contact = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -73,7 +80,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
$this->fees = new ArrayCollection();
|
||||
$this->applications = new ArrayCollection();
|
||||
$this->dispositions = new ArrayCollection();
|
||||
$this->requirements = new ArrayCollection();
|
||||
$this->benefits = BenefitsDto::$defaults;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -127,7 +134,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
return $this->dateFrom;
|
||||
}
|
||||
|
||||
public function setDateFrom(\DateTimeImmutable $dateFrom): static
|
||||
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
|
||||
{
|
||||
$this->dateFrom = $dateFrom;
|
||||
|
||||
@@ -139,7 +146,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
return $this->dateTo;
|
||||
}
|
||||
|
||||
public function setDateTo(\DateTimeImmutable $dateTo): static
|
||||
public function setDateTo(?\DateTimeImmutable $dateTo): static
|
||||
{
|
||||
$this->dateTo = $dateTo;
|
||||
|
||||
@@ -163,19 +170,19 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
return $this->pickup;
|
||||
}
|
||||
|
||||
public function setPickup(?int $pickup): static
|
||||
public function setPickup(null|int|string $pickup): static
|
||||
{
|
||||
$this->pickup = $pickup;
|
||||
$this->pickup = (int) $pickup;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBenefits(): ?string
|
||||
public function getBenefits(): array
|
||||
{
|
||||
return $this->benefits;
|
||||
}
|
||||
|
||||
public function setBenefits(string $benefits): static
|
||||
public function setBenefits(array $benefits): static
|
||||
{
|
||||
$this->benefits = $benefits;
|
||||
|
||||
@@ -194,18 +201,6 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOwner(): ?User
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function setOwner(?User $owner): static
|
||||
{
|
||||
$this->owner = $owner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Fee>
|
||||
*/
|
||||
@@ -290,32 +285,14 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, DispositionRequirement>
|
||||
*/
|
||||
public function getRequirements(): Collection
|
||||
public function getContact(): ?User
|
||||
{
|
||||
return $this->requirements;
|
||||
return $this->contact;
|
||||
}
|
||||
|
||||
public function addRequirement(DispositionRequirement $requirement): static
|
||||
public function setContact(?User $contact): 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);
|
||||
}
|
||||
}
|
||||
$this->contact = $contact;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user