uuid = Uuid::v4(); $this->status = static::STATUS_OPEN; $this->fees = new ArrayCollection(); $this->applications = new ArrayCollection(); $this->dispositions = new ArrayCollection(); $this->teamers = new ArrayCollection(); $this->benefits = "Anreise im E&P Reisebus\nUnterkunft\nVerpflegung\nSkipass\n"; $this->documents = new ArrayCollection(); } public static function duplicate(Assignment $assignment): static { $instance = new static(); $instance ->setDestination($assignment->getDestination()) ->setJobProfile($assignment->getJobProfile()) ->setAvailableDispositions($assignment->getAvailableDispositions()) ->setShowAvailableDispositions($assignment->isShowAvailableDispositions()) ->setDateFrom($assignment->getDateFrom()) ->setDateTo($assignment->getDateTo()) ->setPickupDate($assignment->getPickupDate()) ->setPickup($assignment->getPickup()) ->setBenefits($assignment->getBenefits()) ->setContact($assignment->getContact()); $assignment->getFees()->map(function (Fee $fee) use ($instance) { $instance->addFee($fee); }); $assignment->getDocuments()->map(function (Upload $document) use ($instance) { $instance->addDocument($document); }); return $instance; } public function getId(): ?int { return $this->id; } public function getUuid(): string { return $this->uuid; } public function getDestination(): ?Destination { return $this->destination; } public function setDestination(?Destination $destination): static { $this->destination = $destination; return $this; } public function getJobProfile(): ?JobProfile { return $this->jobProfile; } public function setJobProfile(?JobProfile $jobProfile): static { $this->jobProfile = $jobProfile; return $this; } public function getAvailableDispositions(): ?int { return $this->availableDispositions; } public function setAvailableDispositions(?int $availableDispositions): static { $this->availableDispositions = $availableDispositions; return $this; } public function isShowAvailableDispositions(): ?bool { return $this->showAvailableDispositions; } public function setShowAvailableDispositions(bool $showAvailableDispositions): static { $this->showAvailableDispositions = $showAvailableDispositions; 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 getEffectivePeriod(): ?CarbonPeriod { if (null !== $destination = $this->getDestination()) { $dateFrom = $this->getDateFrom() ?? $destination->getDateFrom(); $dateTo = $this->getDateTo() ?? $destination->getDateTo(); return new CarbonPeriod($dateFrom, $dateTo); } return null; } public function getEffectiveDateFrom(): ?\DateTimeImmutable { if (null !== $effectivePeriod = $this->getEffectivePeriod()) { return $effectivePeriod->start->toDateTimeImmutable(); } return null; } public function getEffectiveDateTo(): ?\DateTimeImmutable { if (null !== $effectivePeriod = $this->getEffectivePeriod()) { return $effectivePeriod->end->toDateTimeImmutable(); } return null; } public function getEffectivePickupDate(): ?\DateTimeImmutable { if (null !== $this->pickupDate) { return $this->pickupDate; } if (0 !== (int) $this->pickup && null !== $destination = $this->getDestination()) { return $destination ->getDateFrom() ->modify('-1 day') ; } return null; } public function getPickupDate(): ?\DateTimeImmutable { return $this->pickupDate; } public function setPickupDate(?\DateTimeImmutable $pickupDate): static { $this->pickupDate = $pickupDate; return $this; } public function getPickup(): ?int { return $this->pickup; } public function setPickup(null|int|string $pickup): static { $this->pickup = (int) $pickup; 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; } /** * @return Collection */ 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 */ 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 */ 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; } public function getContact(): ?User { return $this->contact; } public function setContact(?User $contact): static { $this->contact = $contact; return $this; } /** * @return Collection */ public function getTeamers(): Collection { return $this->teamers; } public function addTeamer(Teamer $teamer): static { if (!$this->teamers->contains($teamer)) { $this->teamers->add($teamer); } return $this; } public function removeTeamer(Teamer $teamer): static { $this->teamers->removeElement($teamer); return $this; } /** * @return Collection */ public function getDocuments(): Collection { return $this->documents; } public function addDocument(Upload $document): static { if (!$this->documents->contains($document)) { $this->documents->add($document); } return $this; } public function removeDocument(Upload $document): static { $this->documents->removeElement($document); return $this; } public function getOwner(): ?User { return $this->owner; } public function setOwner(?User $owner): static { $this->owner = $owner; return $this; } public function getStatus(): ?string { return $this->status; } public function setStatus(string $status): static { $this->status = $status; return $this; } }