jsonoptions = $jsonoptions; return $this; } public function getJsonoptions(): ?string { return $this->jsonoptions; } public function setJsonguests(string $jsonguests): self { $this->jsonguests = $jsonguests; return $this; } public function getJsonguests(): ?string { return $this->jsonguests; } public function getResult(): ?array { $this->result=[]; foreach($this->guests as $guest) { foreach($guest->getVotes() as $vote) { $key=$vote->getOption()->getId(); $val=$vote->getVote(); if(!array_key_exists($key,$this->result)) $this->result[$key]=["id"=>$key,"date"=>$vote->getOption()->getDate(),"count"=>0]; if(!is_null($val)) $this->result[$key]["count"]+=$val; } } $columns = array_column($this->result, 'count'); array_multisort($columns, SORT_DESC, $this->result); return $this->result; } public function getDatepurge() { $this->datepurge=new \DateTime('2000-01-01'); foreach($this->options as $option) { if($option->getDate()>$this->datepurge) $this->datepurge=clone($option->getDate()); } $this->datepurge->modify('+10 day'); return $this->datepurge; } public function __construct() { $this->options = new ArrayCollection(); $this->guests = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getTitle(): ?string { return $this->title; } public function setTitle(string $title): self { $this->title = $title; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getPrivate(): ?bool { return $this->private; } public function setPrivate(bool $private): self { $this->private = $private; return $this; } public function getNotification(): ?bool { return $this->notification; } public function setNotification(bool $notification): self { $this->notification = $notification; return $this; } public function getKey(): ?string { return $this->key; } public function setKey(string $key): self { $this->key = $key; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } /** * @return Collection|Option[] */ public function getOptions(): Collection { return $this->options; } public function addOption(Option $option): self { if (!$this->options->contains($option)) { $this->options[] = $option; $option->setSurvey($this); } return $this; } public function removeOption(Option $option): self { if ($this->options->contains($option)) { $this->options->removeElement($option); // set the owning side to null (unless already changed) if ($option->getSurvey() === $this) { $option->setSurvey(null); } } return $this; } /** * @return Collection|Guest[] */ public function getGuests(): Collection { return $this->guests; } public function addGuest(Guest $guest): self { if (!$this->guests->contains($guest)) { $this->guests[] = $guest; $guest->setSurvey($this); } return $this; } public function removeGuest(Guest $guest): self { if ($this->guests->contains($guest)) { $this->guests->removeElement($guest); // set the owning side to null (unless already changed) if ($guest->getSurvey() === $this) { $guest->setSurvey(null); } } return $this; } public function getStatus(): ?int { return $this->status; } public function setStatus(int $status): self { $this->status = $status; return $this; } public function getTonotifyclose(): ?bool { return $this->tonotifyclose; } public function setTonotifyclose(bool $tonotifyclose): self { $this->tonotifyclose = $tonotifyclose; return $this; } public function getTonotifyopen(): ?bool { return $this->tonotifyopen; } public function setTonotifyopen(bool $tonotifyopen): self { $this->tonotifyopen = $tonotifyopen; return $this; } public function getTonotifymessage(): ?string { return $this->tonotifymessage; } public function setTonotifymessage(?string $tonotifymessage): self { $this->tonotifymessage = $tonotifymessage; return $this; } }