src/Entity/Gos/Uniqskills/OrderCycle.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills;
  3. use App\Entity\Gos\OrderProductVariant;
  4. use App\Entity\Gos\ProductPack;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\OrderCycleRepository")
  10.  * @ORM\HasLifecycleCallbacks()
  11.  */
  12. class OrderCycle
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      * @ORM\GeneratedValue()
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="boolean", nullable=true)
  22.      */
  23.     private $isCancelled;
  24.     /**
  25.      * @ORM\Column(type="integer")
  26.      */
  27.     private $currentLevel;
  28.     /**
  29.      * @ORM\Column(type="boolean", nullable=true)
  30.      */
  31.     private $hasFinished;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductPack", inversedBy="orderCycles")
  34.      */
  35.     private $cyclePack;
  36.     /**
  37.      * @ORM\Column(type="datetime")
  38.      */
  39.     private $createdAt;
  40.     /**
  41.      * @ORM\Column(type="datetime", nullable=true)
  42.      */
  43.     private $updatedAt;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\OrderProductVariant", mappedBy="cycle")
  46.      */
  47.     private $orderProductVariants;
  48.     /**
  49.      * @ORM\Column(type="integer")
  50.      */
  51.     private $maxLevel;
  52.     /**
  53.      * @ORM\Column(type="datetime", nullable=true)
  54.      */
  55.     private $autoProceedAt;
  56.     public function __construct()
  57.     {
  58.         $this->orderProductVariants = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     /** @ORM\PrePersist() */
  65.     public function onPrePersist(): void
  66.     {
  67.         $this->createdAt = new \DateTime();
  68.     }
  69.     /** @ORM\PreUpdate() */
  70.     public function onPreUpdate(): void
  71.     {
  72.         $this->updatedAt = new \DateTime();
  73.     }
  74.     public function getIsCancelled(): ?bool
  75.     {
  76.         return $this->isCancelled;
  77.     }
  78.     public function setIsCancelled(?bool $isCancelled): self
  79.     {
  80.         $this->isCancelled $isCancelled;
  81.         return $this;
  82.     }
  83.     public function getCurrentLevel(): ?int
  84.     {
  85.         return $this->currentLevel;
  86.     }
  87.     public function setCurrentLevel(int $currentLevel): self
  88.     {
  89.         $this->currentLevel $currentLevel;
  90.         return $this;
  91.     }
  92.     public function getHasFinished(): ?bool
  93.     {
  94.         return $this->hasFinished;
  95.     }
  96.     public function setHasFinished(?bool $hasFinished): self
  97.     {
  98.         $this->hasFinished $hasFinished;
  99.         return $this;
  100.     }
  101.     public function getCyclePack(): ?ProductPack
  102.     {
  103.         return $this->cyclePack;
  104.     }
  105.     public function setCyclePack(?ProductPack $cyclePack): self
  106.     {
  107.         $this->cyclePack $cyclePack;
  108.         return $this;
  109.     }
  110.     public function getCreatedAt(): ?\DateTimeInterface
  111.     {
  112.         return $this->createdAt;
  113.     }
  114.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  115.     {
  116.         $this->createdAt $createdAt;
  117.         return $this;
  118.     }
  119.     public function getUpdatedAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->updatedAt;
  122.     }
  123.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  124.     {
  125.         $this->updatedAt $updatedAt;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection|OrderProductVariant[]
  130.      */
  131.     public function getOrderProductVariants(): Collection
  132.     {
  133.         return $this->orderProductVariants;
  134.     }
  135.     public function addOrderProductVariant(OrderProductVariant $orderProductVariant): self
  136.     {
  137.         if (!$this->orderProductVariants->contains($orderProductVariant)) {
  138.             $this->orderProductVariants[] = $orderProductVariant;
  139.             $orderProductVariant->setCycle($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeOrderProductVariant(OrderProductVariant $orderProductVariant): self
  144.     {
  145.         if ($this->orderProductVariants->contains($orderProductVariant)) {
  146.             $this->orderProductVariants->removeElement($orderProductVariant);
  147.             // set the owning side to null (unless already changed)
  148.             if ($orderProductVariant->getCycle() === $this) {
  149.                 $orderProductVariant->setCycle(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154.     public function getMaxLevel(): ?int
  155.     {
  156.         return $this->maxLevel;
  157.     }
  158.     public function setMaxLevel(int $maxLevel): self
  159.     {
  160.         $this->maxLevel $maxLevel;
  161.         return $this;
  162.     }
  163.     public function getCurrentCourse(): ?Course
  164.     {
  165.         $currentOrderVariant $this->getOrderProductVariants()->get($this->getCurrentLevel() - 1);
  166.         $currentVariant $currentOrderVariant->getProductVariant();
  167.         $currentCourse $currentVariant->getCourses()->first();
  168.         return $currentCourse;
  169.     }
  170.     public function getAutoProceedAt(): ?\DateTimeInterface
  171.     {
  172.         return $this->autoProceedAt;
  173.     }
  174.     public function setAutoProceedAt(?\DateTimeInterface $autoProceedAt): self
  175.     {
  176.         $this->autoProceedAt $autoProceedAt;
  177.         return $this;
  178.     }
  179. }