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

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills;
  3. use App\Entity\Gos\ProductVariant;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table()
  9.  * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\PackageRepository")
  10.  * @ORM\HasLifecycleCallbacks()
  11.  */
  12. class Package
  13. {
  14.     /**
  15.      * @ORM\Column(type="integer")
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue(strategy="IDENTITY")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="boolean", nullable=true)
  22.      */
  23.     private $isActive;
  24.     /**
  25.      * @ORM\Column(type="string", nullable=false, length=255)
  26.      */
  27.     private $name;
  28.     /**
  29.      * @ORM\Column(type="datetime")
  30.      */
  31.     private $createdAt;
  32.     /**
  33.      * @ORM\Column(type="datetime", nullable=true)
  34.      */
  35.     private $updatedAt;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="Course", inversedBy="package")
  38.      * @ORM\JoinColumn(onDelete="CASCADE")
  39.      */
  40.     private $course;
  41.     /**
  42.      * @ORM\ManyToMany(targetEntity="Module", inversedBy="package")
  43.      * @ORM\JoinTable(name="package_module_access")
  44.      */
  45.     private $modules;
  46.     /**
  47.      * @ORM\ManyToMany(targetEntity="Lesson", inversedBy="package")
  48.      * @ORM\JoinTable(name="package_lesson_access")
  49.      */
  50.     private $lessons;
  51.     /**
  52.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariant", mappedBy="packages")
  53.      */
  54.     private $productVariants;
  55.     /**
  56.      * @ORM\PrePersist()
  57.      */
  58.     public function prePersist()
  59.     {
  60.         $this->createdAt = new \DateTime();
  61.     }
  62.     /**
  63.      * @ORM\PreUpdate()
  64.      */
  65.     public function preUpdate()
  66.     {
  67.         $this->updatedAt = new \DateTime();
  68.     }
  69.     public function __toString()
  70.     {
  71.         return (string)$this->name;
  72.     }
  73.     /**
  74.      * Package constructor.
  75.      */
  76.     public function __construct()
  77.     {
  78.         $this->modules      = new \Doctrine\Common\Collections\ArrayCollection();
  79.         $this->lessons      = new \Doctrine\Common\Collections\ArrayCollection();
  80.         $this->subscription = new \Doctrine\Common\Collections\ArrayCollection();
  81.         $this->productVariants = new ArrayCollection();
  82.     }
  83.     /* ****************************** GETTERS & SETTERS ******************************  */
  84.     public function getId(): ?int
  85.     {
  86.         return $this->id;
  87.     }
  88.     public function getIsActive(): ?bool
  89.     {
  90.         return $this->isActive;
  91.     }
  92.     public function setIsActive(?bool $isActive): self
  93.     {
  94.         $this->isActive $isActive;
  95.         return $this;
  96.     }
  97.     public function getName(): ?string
  98.     {
  99.         return $this->name;
  100.     }
  101.     public function setName(string $name): self
  102.     {
  103.         $this->name $name;
  104.         return $this;
  105.     }
  106.     public function getCreatedAt(): ?\DateTimeInterface
  107.     {
  108.         return $this->createdAt;
  109.     }
  110.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  111.     {
  112.         $this->createdAt $createdAt;
  113.         return $this;
  114.     }
  115.     public function getUpdatedAt(): ?\DateTimeInterface
  116.     {
  117.         return $this->updatedAt;
  118.     }
  119.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  120.     {
  121.         $this->updatedAt $updatedAt;
  122.         return $this;
  123.     }
  124.     public function getCourse(): ?Course
  125.     {
  126.         return $this->course;
  127.     }
  128.     public function setCourse(?Course $course): self
  129.     {
  130.         $this->course $course;
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection|Module[]
  135.      */
  136.     public function getModules(): Collection
  137.     {
  138.         return $this->modules;
  139.     }
  140.     public function addModule(Module $module): self
  141.     {
  142.         if (!$this->modules->contains($module)) {
  143.             $this->modules[] = $module;
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeModule(Module $module): self
  148.     {
  149.         if ($this->modules->contains($module)) {
  150.             $this->modules->removeElement($module);
  151.         }
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Collection|Lesson[]
  156.      */
  157.     public function getLessons(): Collection
  158.     {
  159.         return $this->lessons;
  160.     }
  161.     public function addLesson(Lesson $lesson): self
  162.     {
  163.         if (!$this->lessons->contains($lesson)) {
  164.             $this->lessons[] = $lesson;
  165.         }
  166.         return $this;
  167.     }
  168.     public function removeLesson(Lesson $lesson): self
  169.     {
  170.         if ($this->lessons->contains($lesson)) {
  171.             $this->lessons->removeElement($lesson);
  172.         }
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return Collection|ProductVariant[]
  177.      */
  178.     public function getProductVariants(): Collection
  179.     {
  180.         return $this->productVariants;
  181.     }
  182.     public function addProductVariant(ProductVariant $productVariant): self
  183.     {
  184.         if (!$this->productVariants->contains($productVariant)) {
  185.             $this->productVariants[] = $productVariant;
  186.             $productVariant->addPackage($this);
  187.         }
  188.         return $this;
  189.     }
  190.     public function removeProductVariant(ProductVariant $productVariant): self
  191.     {
  192.         if ($this->productVariants->contains($productVariant)) {
  193.             $this->productVariants->removeElement($productVariant);
  194.             $productVariant->removePackage($this);
  195.         }
  196.         return $this;
  197.     }
  198. }