<?phpnamespace App\Entity\Gos\Uniqskills;use App\Entity\Gos\OrderProductVariant;use App\Entity\Gos\ProductPack;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\OrderCycleRepository") * @ORM\HasLifecycleCallbacks() */class OrderCycle{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="boolean", nullable=true) */ private $isCancelled; /** * @ORM\Column(type="integer") */ private $currentLevel; /** * @ORM\Column(type="boolean", nullable=true) */ private $hasFinished; /** * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductPack", inversedBy="orderCycles") */ private $cyclePack; /** * @ORM\Column(type="datetime") */ private $createdAt; /** * @ORM\Column(type="datetime", nullable=true) */ private $updatedAt; /** * @ORM\OneToMany(targetEntity="App\Entity\Gos\OrderProductVariant", mappedBy="cycle") */ private $orderProductVariants; /** * @ORM\Column(type="integer") */ private $maxLevel; /** * @ORM\Column(type="datetime", nullable=true) */ private $autoProceedAt; public function __construct() { $this->orderProductVariants = new ArrayCollection(); } public function getId(): ?int { return $this->id; } /** @ORM\PrePersist() */ public function onPrePersist(): void { $this->createdAt = new \DateTime(); } /** @ORM\PreUpdate() */ public function onPreUpdate(): void { $this->updatedAt = new \DateTime(); } public function getIsCancelled(): ?bool { return $this->isCancelled; } public function setIsCancelled(?bool $isCancelled): self { $this->isCancelled = $isCancelled; return $this; } public function getCurrentLevel(): ?int { return $this->currentLevel; } public function setCurrentLevel(int $currentLevel): self { $this->currentLevel = $currentLevel; return $this; } public function getHasFinished(): ?bool { return $this->hasFinished; } public function setHasFinished(?bool $hasFinished): self { $this->hasFinished = $hasFinished; return $this; } public function getCyclePack(): ?ProductPack { return $this->cyclePack; } public function setCyclePack(?ProductPack $cyclePack): self { $this->cyclePack = $cyclePack; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } /** * @return Collection|OrderProductVariant[] */ public function getOrderProductVariants(): Collection { return $this->orderProductVariants; } public function addOrderProductVariant(OrderProductVariant $orderProductVariant): self { if (!$this->orderProductVariants->contains($orderProductVariant)) { $this->orderProductVariants[] = $orderProductVariant; $orderProductVariant->setCycle($this); } return $this; } public function removeOrderProductVariant(OrderProductVariant $orderProductVariant): self { if ($this->orderProductVariants->contains($orderProductVariant)) { $this->orderProductVariants->removeElement($orderProductVariant); // set the owning side to null (unless already changed) if ($orderProductVariant->getCycle() === $this) { $orderProductVariant->setCycle(null); } } return $this; } public function getMaxLevel(): ?int { return $this->maxLevel; } public function setMaxLevel(int $maxLevel): self { $this->maxLevel = $maxLevel; return $this; } public function getCurrentCourse(): ?Course { $currentOrderVariant = $this->getOrderProductVariants()->get($this->getCurrentLevel() - 1); $currentVariant = $currentOrderVariant->getProductVariant(); $currentCourse = $currentVariant->getCourses()->first(); return $currentCourse; } public function getAutoProceedAt(): ?\DateTimeInterface { return $this->autoProceedAt; } public function setAutoProceedAt(?\DateTimeInterface $autoProceedAt): self { $this->autoProceedAt = $autoProceedAt; return $this; }}