src/Entity/Gos/Uniqskills/Lesson.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Table()
  12.  * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\LessonRepository")
  13.  * @ORM\HasLifecycleCallbacks
  14.  * @Vich\Uploadable
  15.  */
  16. class Lesson
  17. {
  18.     /**
  19.      * @ORM\Column(type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="IDENTITY")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="boolean", nullable=true)
  26.      */
  27.     private $isActive;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $name;
  32.     /**
  33.      * @Gedmo\Slug(fields={"name"})
  34.      * @ORM\Column(type="string", length=191, unique=true)
  35.      */
  36.     private $slug;
  37.     /**
  38.      * @ORM\Column(type="boolean", nullable=true)
  39.      */
  40.     private $reminderNewLesson;
  41.     /**
  42.      * @ORM\Column(type="integer")
  43.      */
  44.     private $itemOrder;
  45.     /**
  46.      * @ORM\Column(type="datetime", nullable=true)
  47.      */
  48.     private $shareDate;
  49.     /**
  50.      * @ORM\Column(type="integer", nullable=true)
  51.      */
  52.     private $shareDays;
  53.     /**
  54.      * @ORM\Column(type="text", nullable=true)
  55.      */
  56.     private $content;
  57.     /**
  58.      * @ORM\Column(type="datetime")
  59.      */
  60.     private $createdAt;
  61.     /**
  62.      * @ORM\Column(type="datetime", nullable=true)
  63.      */
  64.     private $updatedAt;
  65.     /**
  66.      * @ORM\ManyToOne(targetEntity="LessonType", fetch="EAGER")
  67.      * @ORM\JoinColumn(name="lesson_type_id", referencedColumnName="id")
  68.      */
  69.     private $lessonType;
  70.     /**
  71.      * @ORM\OneToMany(targetEntity="LessonReminder", mappedBy="lesson")
  72.      */
  73.     private $lessonReminder;
  74.     /**
  75.      * @ORM\OneToMany(targetEntity="UserLesson", mappedBy="lesson")
  76.      */
  77.     private $userLesson;
  78.     /**
  79.      * @ORM\ManyToMany(targetEntity="Package", mappedBy="lessons")
  80.      * @ORM\JoinColumn()
  81.      */
  82.     private $package;
  83.     /**
  84.      * @ORM\ManyToOne(targetEntity="Module", inversedBy="lesson")
  85.      * @ORM\JoinColumn(onDelete="CASCADE")
  86.      */
  87.     private $module;
  88.     /**
  89.      * @ORM\ManyToOne(targetEntity="Author", inversedBy="lesson")
  90.      * @ORM\JoinColumn()
  91.      */
  92.     private $author;
  93.     /**
  94.      * @ORM\Column(type="string", length=255, nullable=true)
  95.      * @var string
  96.      */
  97.     private $advertisementPhoto;
  98.     /**
  99.      * @Vich\UploadableField(mapping="advertisement_image", fileNameProperty="advertisementPhoto")
  100.      * @var File
  101.      */
  102.     private $advertisementPhotoFile;
  103.     /**
  104.      * @ORM\Column(type="string", length=255, nullable=true)
  105.      */
  106.     private $advertisementVideoLink;
  107.     /**
  108.      * @ORM\Column(type="integer", nullable=true)
  109.      */
  110.     private $videoId;
  111.     /**
  112.      * @ORM\OneToMany(targetEntity=UserVideoNotes::class, mappedBy="lesson")
  113.      */
  114.     private $userVideoNotes;
  115.     /**
  116.      * @ORM\Column(type="string", length=255, nullable=true)
  117.      */
  118.     private $linkToAdvertisementPhoto;
  119.     /**
  120.      * @ORM\Column(type="string", length=255, nullable=true)
  121.      */
  122.     private $linkToAdvertisementVideo;
  123.     /**
  124.      * GOS-1860
  125.      * After how many days from the order should lesson be visible in customer panel
  126.      * default: 0 - visible immediately
  127.      * @ORM\Column(type="integer", options={"default": 0})
  128.      * @Assert\GreaterThanOrEqual(value=0)
  129.      */
  130.     private $visibleAfterDays 0;
  131.     /** @ORM\PrePersist() */
  132.     public function prePersist()
  133.     {
  134.         $this->createdAt = new \DateTime();
  135.     }
  136.     /** @ORM\PreUpdate() */
  137.     public function preUpdate()
  138.     {
  139.         $this->updatedAt = new \DateTime();
  140.     }
  141.     public function __toString()
  142.     {
  143.         return (string)$this->name;
  144.     }
  145.     public function __clone()
  146.     {
  147.         $this->id           null;
  148.         $this->updatedAt    null;
  149.     }
  150.     /**
  151.      * Constructor
  152.      */
  153.     public function __construct()
  154.     {
  155.         $this->userLesson = new \Doctrine\Common\Collections\ArrayCollection();
  156.         $this->package    = new \Doctrine\Common\Collections\ArrayCollection();
  157.         $this->lessonReminder = new ArrayCollection();
  158.         $this->userVideoNotes = new ArrayCollection();
  159.     }
  160.     /**
  161.      * Add userLesson
  162.      *
  163.      * @param \App\Entity\Gos\Uniqskills\UserLesson $userLesson
  164.      * @return Lesson
  165.      */
  166.     public function addUserLesson(\App\Entity\Gos\Uniqskills\UserLesson $userLesson)
  167.     {
  168.         $this->userLesson[] = $userLesson;
  169.         return $this;
  170.     }
  171.     /**
  172.      * Remove userLesson
  173.      *
  174.      * @param \App\Entity\Gos\Uniqskills\UserLesson $userLesson
  175.      */
  176.     public function removeUserLesson(\App\Entity\Gos\Uniqskills\UserLesson $userLesson)
  177.     {
  178.         $this->userLesson->removeElement($userLesson);
  179.     }
  180.     /**
  181.      * Get userLesson
  182.      *
  183.      * @return \Doctrine\Common\Collections\Collection
  184.      */
  185.     public function getUserLesson()
  186.     {
  187.         return $this->userLesson;
  188.     }
  189.     /* ****************************** GETTERS & SETTERS ******************************  */
  190.     public function getId(): ?int
  191.     {
  192.         return $this->id;
  193.     }
  194.     public function getIsActive(): ?bool
  195.     {
  196.         return $this->isActive;
  197.     }
  198.     public function setIsActive(?bool $isActive): self
  199.     {
  200.         $this->isActive $isActive;
  201.         return $this;
  202.     }
  203.     public function getName(): ?string
  204.     {
  205.         return $this->name;
  206.     }
  207.     public function setName(string $name): self
  208.     {
  209.         $this->name $name;
  210.         return $this;
  211.     }
  212.     public function getSlug(): ?string
  213.     {
  214.         return $this->slug;
  215.     }
  216.     public function setSlug($slug): self
  217.     {
  218.         $this->slug $slug;
  219.         return $this;
  220.     }
  221.     public function getReminderNewLesson(): ?bool
  222.     {
  223.         return $this->reminderNewLesson;
  224.     }
  225.     public function setReminderNewLesson(?bool $reminderNewLesson): self
  226.     {
  227.         $this->reminderNewLesson $reminderNewLesson;
  228.         return $this;
  229.     }
  230.     public function getItemOrder(): ?int
  231.     {
  232.         return $this->itemOrder;
  233.     }
  234.     public function setItemOrder(int $itemOrder): self
  235.     {
  236.         $this->itemOrder $itemOrder;
  237.         return $this;
  238.     }
  239.     public function getShareDate(): ?\DateTimeInterface
  240.     {
  241.         return $this->shareDate;
  242.     }
  243.     public function setShareDate(?\DateTimeInterface $shareDate): self
  244.     {
  245.         $this->shareDate $shareDate;
  246.         return $this;
  247.     }
  248.     public function getShareDays(): ?int
  249.     {
  250.         return $this->shareDays;
  251.     }
  252.     public function setShareDays(?int $shareDays): self
  253.     {
  254.         $this->shareDays $shareDays;
  255.         return $this;
  256.     }
  257.     public function getContent(): ?string
  258.     {
  259.         return $this->content;
  260.     }
  261.     public function setContent(?string $content): self
  262.     {
  263.         $this->content $content;
  264.         return $this;
  265.     }
  266.     public function getCreatedAt(): ?\DateTimeInterface
  267.     {
  268.         return $this->createdAt;
  269.     }
  270.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  271.     {
  272.         $this->createdAt $createdAt;
  273.         return $this;
  274.     }
  275.     public function getUpdatedAt(): ?\DateTimeInterface
  276.     {
  277.         return $this->updatedAt;
  278.     }
  279.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  280.     {
  281.         $this->updatedAt $updatedAt;
  282.         return $this;
  283.     }
  284.     public function getLessonType(): ?LessonType
  285.     {
  286.         return $this->lessonType;
  287.     }
  288.     public function setLessonType(?LessonType $lessonType): self
  289.     {
  290.         $this->lessonType $lessonType;
  291.         return $this;
  292.     }
  293.     /**
  294.      * @return Collection|LessonReminder[]
  295.      */
  296.     public function getLessonReminder(): Collection
  297.     {
  298.         return $this->lessonReminder;
  299.     }
  300.     public function addLessonReminder(LessonReminder $lessonReminder): self
  301.     {
  302.         if (!$this->lessonReminder->contains($lessonReminder)) {
  303.             $this->lessonReminder[] = $lessonReminder;
  304.             $lessonReminder->setLesson($this);
  305.         }
  306.         return $this;
  307.     }
  308.     public function removeLessonReminder(LessonReminder $lessonReminder): self
  309.     {
  310.         if ($this->lessonReminder->contains($lessonReminder)) {
  311.             $this->lessonReminder->removeElement($lessonReminder);
  312.             // set the owning side to null (unless already changed)
  313.             if ($lessonReminder->getLesson() === $this) {
  314.                 $lessonReminder->setLesson(null);
  315.             }
  316.         }
  317.         return $this;
  318.     }
  319.     /**
  320.      * @return Collection|Package[]
  321.      */
  322.     public function getPackage(): Collection
  323.     {
  324.         return $this->package;
  325.     }
  326.     public function addPackage(Package $package): self
  327.     {
  328.         if (!$this->package->contains($package)) {
  329.             $this->package[] = $package;
  330.             $package->addLesson($this);
  331.         }
  332.         return $this;
  333.     }
  334.     public function removePackage(Package $package): self
  335.     {
  336.         if ($this->package->contains($package)) {
  337.             $this->package->removeElement($package);
  338.             $package->removeLesson($this);
  339.         }
  340.         return $this;
  341.     }
  342.     public function getModule(): ?Module
  343.     {
  344.         return $this->module;
  345.     }
  346.     public function setModule(?Module $module): self
  347.     {
  348.         $this->module $module;
  349.         return $this;
  350.     }
  351.     public function getAuthor(): ?Author
  352.     {
  353.         return $this->author;
  354.     }
  355.     public function setAuthor(?Author $author): self
  356.     {
  357.         $this->author $author;
  358.         return $this;
  359.     }
  360.     public function getAdvertisementPhoto(): ?string
  361.     {
  362.         return $this->advertisementPhoto;
  363.     }
  364.     public function setAdvertisementPhoto(?string $advertisementPhoto): self
  365.     {
  366.         $this->advertisementPhoto $advertisementPhoto;
  367.         return $this;
  368.     }
  369.     public function setAdvertisementPhotoFile(File $advertisementPhotoFile null)
  370.     {
  371.         $this->advertisementPhotoFile $advertisementPhotoFile;
  372.         if ($advertisementPhotoFile) {
  373.             $this->updatedAt = new \DateTime('now');
  374.         }
  375.     }
  376.     public function getAdvertisementPhotoFile()
  377.     {
  378.         return $this->advertisementPhotoFile;
  379.     }
  380.     public function getAdvertisementVideoLink(): ?string
  381.     {
  382.         return $this->advertisementVideoLink;
  383.     }
  384.     public function setAdvertisementVideoLink(?string $advertisementVideoLink): self
  385.     {
  386.         $this->advertisementVideoLink $advertisementVideoLink;
  387.         return $this;
  388.     }
  389.     public function getVideoId(): ?int
  390.     {
  391.         return $this->videoId;
  392.     }
  393.     public function setVideoId(?int $videoId): self
  394.     {
  395.         $this->videoId $videoId;
  396.         return $this;
  397.     }
  398.     /**
  399.      * @return Collection|UserVideoNotes[]
  400.      */
  401.     public function getUserVideoNotes(): Collection
  402.     {
  403.         return $this->userVideoNotes;
  404.     }
  405.     public function addUserVideoNote(UserVideoNotes $userVideoNote): self
  406.     {
  407.         if (!$this->userVideoNotes->contains($userVideoNote)) {
  408.             $this->userVideoNotes[] = $userVideoNote;
  409.             $userVideoNote->setLession($this);
  410.         }
  411.         return $this;
  412.     }
  413.     public function removeUserVideoNote(UserVideoNotes $userVideoNote): self
  414.     {
  415.         if ($this->userVideoNotes->contains($userVideoNote)) {
  416.             $this->userVideoNotes->removeElement($userVideoNote);
  417.             // set the owning side to null (unless already changed)
  418.             if ($userVideoNote->getLession() === $this) {
  419.                 $userVideoNote->setLession(null);
  420.             }
  421.         }
  422.         return $this;
  423.     }
  424.     public function getLinkToAdvertisementPhoto(): ?string
  425.     {
  426.         return $this->linkToAdvertisementPhoto;
  427.     }
  428.     public function setLinkToAdvertisementPhoto(?string $linkToAdvertisementPhoto): self
  429.     {
  430.         $this->linkToAdvertisementPhoto $linkToAdvertisementPhoto;
  431.         return $this;
  432.     }
  433.     public function getLinkToAdvertisementVideo(): ?string
  434.     {
  435.         return $this->linkToAdvertisementVideo;
  436.     }
  437.     public function setLinkToAdvertisementVideo(?string $linkToAdvertisementVideo): self
  438.     {
  439.         $this->linkToAdvertisementVideo $linkToAdvertisementVideo;
  440.         return $this;
  441.     }
  442.     public function getVisibleAfterDays(): ?int
  443.     {
  444.         return $this->visibleAfterDays;
  445.     }
  446.     public function setVisibleAfterDays(int $visibleAfterDays): self
  447.     {
  448.         $this->visibleAfterDays $visibleAfterDays;
  449.         return $this;
  450.     }
  451. }