uuid = Uuid::v4(); $this->author = $author->getFullName(); } public static function fromAssignment(Assignment $assignment, User $user): static { $instance = new static($user); $destination = $assignment->getDestination(); $jobProfile = $assignment->getJobProfile(); $instance ->setAssignmentDateFrom($assignment->getEffectiveDateFrom()) ->setAssignmentDateTo($assignment->getEffectiveDateTo()) ->setDestinationName($destination->getProduct()) ->setHotel($destination->getHotel()) ->setHotelCode($destination->getHotelCode()) ->setHotelBusProId($destination->getHotelBusProId()) ->setJobProfileName($jobProfile->getName()) ; return $instance; } public function getId(): ?int { return $this->id; } public function getUuid(): string { return $this->uuid; } public function getStatus(): ?string { return $this->status; } public function setStatus(string $status): static { $this->status = $status; return $this; } public function getTeamer(): ?Teamer { return $this->teamer; } public function setTeamer(?Teamer $teamer): static { $this->teamer = $teamer; return $this; } public function getDestinationName(): ?string { return $this->destinationName; } public function setDestinationName(string $destinationName): static { $this->destinationName = $destinationName; return $this; } public function getAssignmentDateFrom(): ?\DateTimeImmutable { return $this->assignmentDateFrom; } public function setAssignmentDateFrom(\DateTimeImmutable $assignmentDateFrom): static { $this->assignmentDateFrom = $assignmentDateFrom; return $this; } public function getAssignmentDateTo(): ?\DateTimeImmutable { return $this->assignmentDateTo; } public function setAssignmentDateTo(?\DateTimeImmutable $assignmentDateTo): static { $this->assignmentDateTo = $assignmentDateTo; return $this; } public function getJobProfileName(): ?string { return $this->jobProfileName; } public function setJobProfileName(?string $jobProfileName): static { $this->jobProfileName = $jobProfileName; return $this; } public function getHotel(): ?string { return $this->hotel; } public function setHotel(?string $hotel): static { $this->hotel = $hotel; return $this; } public function getHotelCode(): ?string { return $this->hotelCode; } public function setHotelCode(?string $hotelCode): static { $this->hotelCode = $hotelCode; return $this; } public function getHotelBusProId(): ?int { return $this->hotelBusProId; } public function setHotelBusProId(?int $hotelBusProId): static { $this->hotelBusProId = $hotelBusProId; return $this; } public function getRatings(): array { return $this->ratings; } public function setRatings(array $ratings): static { $this->ratings = $ratings; return $this; } public function getAverageRating(): ?int { return $this->averageRating; } #[ORM\PrePersist] #[ORM\PreUpdate] public function setAverageRating(): static { if (0 === count($this->ratings)) { $this->averageRating = null; return $this; } $sum = 0; foreach ($this->ratings as $rating) { $sum += $rating['mark']; } $this->averageRating = $sum/count($this->ratings) * 100; return $this; } public function getComment(): ?string { return $this->comment; } public function setComment(?string $comment): static { $this->comment = $comment; return $this; } public function getCommentInternal(): ?string { return $this->commentInternal; } public function setCommentInternal(?string $commentInternal): static { $this->commentInternal = $commentInternal; return $this; } public function getAuthor(): ?string { return $this->author; } public function setAuthor(string $author): static { $this->author = $author; return $this; } }