src/Entity/Course.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\CourseRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassCourseRepository::class)]
  10. #[ApiResource]
  11. class Course
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(typeTypes::TEXT)]
  20.     private ?string $description null;
  21.     #[ORM\ManyToMany(targetEntityCatalog::class, inversedBy'courses')]
  22.     private Collection $catalog;
  23.     #[ORM\ManyToOne(inversedBy'courses')]
  24.     private ?CourseTag $courseTag null;
  25.     #[ORM\ManyToMany(targetEntityAttendee::class, inversedBy'courses')]
  26.     private Collection $attendees;
  27.     #[ORM\Column]
  28.     private ?\DateTimeImmutable $createdAt null;
  29.     #[ORM\Column]
  30.     private ?bool $isPublished null;
  31.     #[ORM\ManyToOne(inversedBy'courses')]
  32.     private ?MediaObject $mainImage null;
  33.     #[ORM\OneToMany(mappedBy'course'targetEntityLesson::class, cascade: ['persist'],orphanRemovaltrue)]
  34.     private Collection $lessons;
  35.     #[ORM\OneToMany(mappedBy'course'targetEntityCourseEvaluation::class, cascade: ['persist'])]
  36.     private Collection $courseEvaluations;
  37.     #[ORM\OneToMany(mappedBy'course'targetEntityGivenAnswere::class, cascade: ['persist'])]
  38.     private Collection $givenAnsweres;
  39.     #[ORM\ManyToMany(targetEntityCourseLicense::class, mappedBy'courses'cascade: ['persist'])]
  40.     private Collection $courseLicenses;
  41.     #[ORM\Column]
  42.     private ?bool $abo null;
  43.     #[ORM\Column]
  44.     private ?int $abotime 0;
  45.     #[ORM\OneToMany(mappedBy'course'targetEntityPraxisLesson::class)]
  46.     private Collection $praxisLessons;
  47.     #[ORM\Column(nullabletrue)]
  48.     private ?bool $evaluation null;
  49.     #[ORM\ManyToOne(inversedBy'courses')]
  50.     private ?PortalAdministrator $portalAdmin null;
  51.     #[ORM\Column]
  52.     private ?bool $generateCert null;
  53.     #[ORM\Column(typeTypes::TEXT)]
  54.     private ?string $certDescription null;
  55.     #[ORM\OneToMany(mappedBy'course'targetEntityCertificate::class)]
  56.     private Collection $certificates;
  57.     public function __construct()
  58.     {
  59.         $this->catalog = new ArrayCollection();
  60.         $this->attendees = new ArrayCollection();
  61.         $this->createdAt = new \DateTimeImmutable();
  62.         $this->lessons = new ArrayCollection();
  63.         $this->courseEvaluations = new ArrayCollection();
  64.         $this->givenAnsweres = new ArrayCollection();
  65.         $this->courseLicenses = new ArrayCollection();
  66.         $this->setDescription('Beschreibung');
  67.         $this->praxisLessons = new ArrayCollection();
  68.         $this->certificates = new ArrayCollection();
  69.     }
  70.     public function __toString(): string
  71.     {
  72.         return $this->name;
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getName(): ?string
  79.     {
  80.         return $this->name;
  81.     }
  82.     public function setName(string $name): self
  83.     {
  84.         $this->name $name;
  85.         return $this;
  86.     }
  87.     public function getDescription(): ?string
  88.     {
  89.         return $this->description;
  90.     }
  91.     public function setDescription(string $description): self
  92.     {
  93.         $this->description $description;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @return Collection<int, Catalog>
  98.      */
  99.     public function getCatalog(): Collection
  100.     {
  101.         return $this->catalog;
  102.     }
  103.     public function addCatalog(Catalog $catalog): self
  104.     {
  105.         if (!$this->catalog->contains($catalog)) {
  106.             $this->catalog->add($catalog);
  107.         }
  108.         return $this;
  109.     }
  110.     public function removeCatalog(Catalog $catalog): self
  111.     {
  112.         $this->catalog->removeElement($catalog);
  113.         return $this;
  114.     }
  115.     public function getCourseTag(): ?CourseTag
  116.     {
  117.         return $this->courseTag;
  118.     }
  119.     public function setCourseTag(?CourseTag $courseTag): self
  120.     {
  121.         $this->courseTag $courseTag;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return Collection<int, Attendee>
  126.      */
  127.     public function getAttendees(): Collection
  128.     {
  129.         return $this->attendees;
  130.     }
  131.     public function addAttendee(Attendee $attendee): self
  132.     {
  133.         if (!$this->attendees->contains($attendee)) {
  134.             $this->attendees->add($attendee);
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeAttendee(Attendee $attendee): self
  139.     {
  140.         $this->attendees->removeElement($attendee);
  141.         return $this;
  142.     }
  143.     public function getCreatedAt(): ?\DateTimeImmutable
  144.     {
  145.         return $this->createdAt;
  146.     }
  147.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  148.     {
  149.         $this->createdAt $createdAt;
  150.         return $this;
  151.     }
  152.     public function isIsPublished(): ?bool
  153.     {
  154.         return $this->isPublished;
  155.     }
  156.     public function setIsPublished(bool $isPublished): self
  157.     {
  158.         $this->isPublished $isPublished;
  159.         return $this;
  160.     }
  161.     public function getMainImage(): ?MediaObject
  162.     {
  163.         return $this->mainImage;
  164.     }
  165.     public function setMainImage(?MediaObject $mainImage): self
  166.     {
  167.         $this->mainImage $mainImage;
  168.         return $this;
  169.     }
  170.     /**
  171.      * @return Collection<int, Lesson>
  172.      */
  173.     public function getLessons(): Collection
  174.     {
  175.         return $this->lessons;
  176.     }
  177.     public function addLesson(Lesson $lesson): self
  178.     {
  179.         if (!$this->lessons->contains($lesson)) {
  180.             $this->lessons->add($lesson);
  181.             $lesson->setCourse($this);
  182.         }
  183.         return $this;
  184.     }
  185.     public function removeLesson(Lesson $lesson): self
  186.     {
  187.         if ($this->lessons->removeElement($lesson)) {
  188.             // set the owning side to null (unless already changed)
  189.             if ($lesson->getCourse() === $this) {
  190.                 $lesson->setCourse(null);
  191.             }
  192.         }
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return Collection<int, CourseEvaluation>
  197.      */
  198.     public function getCourseEvaluations(): Collection
  199.     {
  200.         return $this->courseEvaluations;
  201.     }
  202.     public function addCourseEvaluation(CourseEvaluation $courseEvaluation): self
  203.     {
  204.         if (!$this->courseEvaluations->contains($courseEvaluation)) {
  205.             $this->courseEvaluations->add($courseEvaluation);
  206.             $courseEvaluation->setCourse($this);
  207.         }
  208.         return $this;
  209.     }
  210.     public function removeCourseEvaluation(CourseEvaluation $courseEvaluation): self
  211.     {
  212.         if ($this->courseEvaluations->removeElement($courseEvaluation)) {
  213.             // set the owning side to null (unless already changed)
  214.             if ($courseEvaluation->getCourse() === $this) {
  215.                 $courseEvaluation->setCourse(null);
  216.             }
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, GivenAnswere>
  222.      */
  223.     public function getGivenAnsweres(): Collection
  224.     {
  225.         return $this->givenAnsweres;
  226.     }
  227.     public function addGivenAnswere(GivenAnswere $givenAnswere): self
  228.     {
  229.         if (!$this->givenAnsweres->contains($givenAnswere)) {
  230.             $this->givenAnsweres->add($givenAnswere);
  231.             $givenAnswere->setCourse($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeGivenAnswere(GivenAnswere $givenAnswere): self
  236.     {
  237.         if ($this->givenAnsweres->removeElement($givenAnswere)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($givenAnswere->getCourse() === $this) {
  240.                 $givenAnswere->setCourse(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, CourseLicense>
  247.      */
  248.     public function getCourseLicenses(): Collection
  249.     {
  250.         return $this->courseLicenses;
  251.     }
  252.     public function addCourseLicense(CourseLicense $courseLicense): self
  253.     {
  254.         if (!$this->courseLicenses->contains($courseLicense)) {
  255.             $this->courseLicenses->add($courseLicense);
  256.             $courseLicense->addCourse($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeCourseLicense(CourseLicense $courseLicense): self
  261.     {
  262.         if ($this->courseLicenses->removeElement($courseLicense)) {
  263.             $courseLicense->removeCourse($this);
  264.         }
  265.         return $this;
  266.     }
  267.     public function isAbo(): ?bool
  268.     {
  269.         return $this->abo;
  270.     }
  271.     public function setAbo(bool $abo): self
  272.     {
  273.         $this->abo $abo;
  274.         return $this;
  275.     }
  276.     public function getAbotime(): ?int
  277.     {
  278.         return $this->abotime;
  279.     }
  280.     public function setAbotime(int $abotime): self
  281.     {
  282.         $this->abotime $abotime;
  283.         return $this;
  284.     }
  285.     /**
  286.      * @return Collection<int, PraxisLesson>
  287.      */
  288.     public function getPraxisLessons(): Collection
  289.     {
  290.         return $this->praxisLessons;
  291.     }
  292.     public function addPraxisLesson(PraxisLesson $praxisLesson): self
  293.     {
  294.         if (!$this->praxisLessons->contains($praxisLesson)) {
  295.             $this->praxisLessons->add($praxisLesson);
  296.             $praxisLesson->setCourse($this);
  297.         }
  298.         return $this;
  299.     }
  300.     public function removePraxisLesson(PraxisLesson $praxisLesson): self
  301.     {
  302.         if ($this->praxisLessons->removeElement($praxisLesson)) {
  303.             // set the owning side to null (unless already changed)
  304.             if ($praxisLesson->getCourse() === $this) {
  305.                 $praxisLesson->setCourse(null);
  306.             }
  307.         }
  308.         return $this;
  309.     }
  310.     public function isEvaluation(): ?bool
  311.     {
  312.         return $this->evaluation;
  313.     }
  314.     public function setEvaluation(?bool $evaluation): self
  315.     {
  316.         $this->evaluation $evaluation;
  317.         return $this;
  318.     }
  319.     public function getPortalAdmin(): ?PortalAdministrator
  320.     {
  321.         return $this->portalAdmin;
  322.     }
  323.     public function setPortalAdmin(?PortalAdministrator $portalAdmin): self
  324.     {
  325.         $this->portalAdmin $portalAdmin;
  326.         return $this;
  327.     }
  328.     public function isGenerateCert(): ?bool
  329.     {
  330.         return $this->generateCert;
  331.     }
  332.     public function setGenerateCert(bool $generateCert): self
  333.     {
  334.         $this->generateCert $generateCert;
  335.         return $this;
  336.     }
  337.     public function getCertDescription(): ?string
  338.     {
  339.         return $this->certDescription;
  340.     }
  341.     public function setCertDescription(string $certDescription): self
  342.     {
  343.         $this->certDescription $certDescription;
  344.         return $this;
  345.     }
  346.     /**
  347.      * @return Collection<int, Certificate>
  348.      */
  349.     public function getCertificates(): Collection
  350.     {
  351.         return $this->certificates;
  352.     }
  353.     public function addCertificate(Certificate $certificate): self
  354.     {
  355.         if (!$this->certificates->contains($certificate)) {
  356.             $this->certificates->add($certificate);
  357.             $certificate->setCourse($this);
  358.         }
  359.         return $this;
  360.     }
  361.     public function removeCertificate(Certificate $certificate): self
  362.     {
  363.         if ($this->certificates->removeElement($certificate)) {
  364.             // set the owning side to null (unless already changed)
  365.             if ($certificate->getCourse() === $this) {
  366.                 $certificate->setCourse(null);
  367.             }
  368.         }
  369.         return $this;
  370.     }
  371. }