src/Entity/Course.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CourseRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\Criteria;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  10. /**
  11.  * @ORM\Entity(repositoryClass=CourseRepository::class)
  12.  */
  13. class Course extends Base
  14. {
  15.     /**
  16.      * @ORM\ManyToOne(targetEntity=Organizer::class, inversedBy="courses")
  17.      * @ORM\JoinColumn(nullable=false)
  18.      */
  19.     private $organizer;
  20.     /**
  21.      * @ORM\Column(type="boolean")
  22.      */
  23.     private $isCreatedByAdmin;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=Place::class, inversedBy="courses")
  26.      */
  27.     private $place;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     protected $name;
  32.     /**
  33.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  34.      */
  35.     private $price;
  36.     /**
  37.      * @ORM\Column(type="text", nullable=true)
  38.      */
  39.     private $priceDescription;
  40.     /**
  41.      * @ORM\Column(type="text", nullable=true)
  42.      */
  43.     private $shortDescription;
  44.     /**
  45.      * @ORM\Column(type="text", nullable=true)
  46.      */
  47.     private $description;
  48.     /**
  49.      * @ORM\Column(type="text", nullable=true)
  50.      */
  51.     private $requirements;
  52.     /**
  53.      * @ORM\Column(type="datetime", nullable=true)
  54.      */
  55.     private $publishedAt;
  56.     /**
  57.      * @ORM\Column(type="datetime", nullable=true)
  58.      */
  59.     private $endAt;
  60.     /**
  61.      * @ORM\Column(type="integer", nullable=true)
  62.      */
  63.     private $length;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity=CourseState::class)
  66.      * @ORM\JoinColumn(nullable=false)
  67.      */
  68.     private $state;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=CourseType::class, inversedBy="courses")
  71.      */
  72.     private $type;
  73.     /**
  74.      * @ORM\Column(type="boolean")
  75.      */
  76.     private $canCustomize;
  77.     /**
  78.      * @ORM\Column(type="boolean")
  79.      */
  80.     private $isPreparationForCertification;
  81.     /**
  82.      * @ORM\Column(type="boolean")
  83.      */
  84.     private $isWithCertificate;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity=Certification::class)
  87.      */
  88.     private $certificate;
  89.     /**
  90.      * @ORM\ManyToOne(targetEntity=CourseFrequency::class)
  91.      */
  92.     private $frequency;
  93.     /**
  94.      * @ORM\ManyToOne(targetEntity=CoursePlaceType::class)
  95.      * @ORM\JoinColumn(nullable=true)
  96.      */
  97.     private $placeType;
  98.     /**
  99.      * @ORM\Column(type="boolean")
  100.      */
  101.     private $canBuy;
  102.     /**
  103.      * @ORM\Column(type="boolean")
  104.      */
  105.     private $canRegister;
  106.     /**
  107.      * @ORM\OneToMany(targetEntity=CourseReview::class, mappedBy="course", cascade={"persist", "remove"})
  108.      */
  109.     private $reviews;
  110.     /**
  111.      * @ORM\OneToMany(targetEntity=CourseStats::class, mappedBy="course", cascade={"persist", "remove"})
  112.      */
  113.     private $stats;
  114.     /**
  115.      * @ORM\ManyToMany(targetEntity=Attribute::class)
  116.      */
  117.     private $attributes;
  118.     /**
  119.      * @ORM\ManyToMany(targetEntity=Lecturer::class, inversedBy="courses")
  120.      */
  121.     private $lecturers;
  122.     /**
  123.      * @ORM\ManyToMany(targetEntity=Tag::class)
  124.      */
  125.     private $tags;
  126.     /**
  127.      * @ORM\ManyToMany(targetEntity=Promoter::class, inversedBy="courses")
  128.      */
  129.     private $promoters;
  130.     /**
  131.      * @ORM\ManyToOne(targetEntity=CourseTopic::class, inversedBy="courses")
  132.      * @ORM\JoinColumn(nullable=true)
  133.      */
  134.     private $topic;
  135.     /**
  136.      * @ORM\Column(type="string", length=255)
  137.      * @Assert\Email()
  138.      */
  139.     private $email;
  140.     /**
  141.      * @ORM\Column(type="boolean", nullable=true)
  142.      */
  143.     private $canPaid;
  144.     /**
  145.      * @ORM\ManyToMany(targetEntity=DayInWeek::class)
  146.      */
  147.     private $dayInWeeks;
  148.     /**
  149.      * @ORM\Column(type="string", length=255, nullable=true)
  150.      */
  151.     private $frequencyText;
  152.     /**
  153.      * @ORM\Column(type="time", nullable=true)
  154.      */
  155.     private $lessonStart;
  156.     /**
  157.      * @ORM\Column(type="time", nullable=true)
  158.      */
  159.     private $lessonEnd;
  160.     /**
  161.      * @ORM\ManyToOne(targetEntity=CourseLength::class)
  162.      */
  163.     private $lengthType;
  164.     /**
  165.      * @ORM\ManyToOne(targetEntity=CourseProgressLevel::class)
  166.      */
  167.     private $progressLevel;
  168.     /**
  169.      * @ORM\ManyToOne(targetEntity=LanguageLevel::class)
  170.      */
  171.     private $languageLevelInput;
  172.     /**
  173.      * @ORM\ManyToOne(targetEntity=LanguageLevel::class)
  174.      */
  175.     private $languageLevelOutput;
  176.     /**
  177.      * @ORM\Column(type="boolean", nullable=true)
  178.      */
  179.     private $isConfirmationOfParticipation;
  180.     /**
  181.      * @ORM\Column(type="boolean", nullable=true)
  182.      */
  183.     private $certificationPriceNotIncluded;
  184.     /**
  185.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  186.      */
  187.     private $certificationPrice;
  188.     /**
  189.      * @ORM\Column(type="string", length=255, nullable=true)
  190.      */
  191.     private $confirmationName;
  192.     /**
  193.      * @ORM\ManyToOne(targetEntity=City::class)
  194.      */
  195.     private $city;
  196.     /**
  197.      * @ORM\Column(type="string", length=255, nullable=true)
  198.      */
  199.     private $url;
  200.     /**
  201.      * @ORM\Column(type="string", length=255, nullable=true)
  202.      */
  203.     private $code;
  204.     /**
  205.      * @ORM\Column(type="boolean", nullable=true)
  206.      */
  207.     private $isRecommended;
  208.     /**
  209.      * @ORM\Column(type="float")
  210.      */
  211.     private $rating;
  212.     /**
  213.      * @ORM\Column(type="boolean")
  214.      */
  215.     private $isNativeSpeaker;
  216.     /**
  217.      * @ORM\Column(type="boolean")
  218.      */
  219.     private $isCustomized;
  220.     /**
  221.      * @ORM\ManyToOne(targetEntity=TeachingType::class)
  222.      */
  223.     private $teachingType;
  224.     /**
  225.      * @ORM\ManyToOne(targetEntity=RetrainingType::class)
  226.      */
  227.     private $retrainingType;
  228.     /**
  229.      * @ORM\Column(type="boolean", nullable=true)
  230.      */
  231.     private $onlyForAdults;
  232.     /**
  233.      * @ORM\Column(type="integer")
  234.      */
  235.     private $lastStep;
  236.     /**
  237.      * @ORM\OneToMany(targetEntity=CourseTerm::class, mappedBy="course", orphanRemoval=true, cascade={"persist", "remove"})
  238.      */
  239.     private $terms;
  240.     /**
  241.      * @ORM\Column(type="text", nullable=true)
  242.      */
  243.     private $placeDescription;
  244.     /**
  245.      * @ORM\Column(type="decimal", precision=10, scale=8, nullable=true)
  246.      */
  247.     private $latitude;
  248.     /**
  249.      * @ORM\Column(type="decimal", precision=11, scale=8, nullable=true)
  250.      */
  251.     private $longitude;
  252.     /**
  253.      * @ORM\ManyToOne(targetEntity=TargetGroup::class)
  254.      */
  255.     private $targetGroup;
  256.     public function __construct()
  257.     {
  258.         parent::__construct();
  259.         $this->reviews = new ArrayCollection();
  260.         $this->stats = new ArrayCollection();
  261.         $this->attributes = new ArrayCollection();
  262.         $this->lecturers = new ArrayCollection();
  263.         $this->tags = new ArrayCollection();
  264.         $this->promoters = new ArrayCollection();
  265.         $this->dayInWeeks = new ArrayCollection();
  266.         $this->isCreatedByAdmin false;
  267.         $this->canCustomize false;
  268.         $this->canBuy false;
  269.         $this->isRecommended false;
  270.         $this->rating 0;
  271.         $this->lastStep 1;
  272.         $this->isCustomized false;
  273.         $this->isNativeSpeaker false;
  274.         $this->terms = new ArrayCollection();
  275.         $endAt = new \DateTime();
  276.         $endAt->modify('+6 months');
  277.         $this->endAt $endAt;
  278.     }
  279.     public function getOrganizer(): ?Organizer
  280.     {
  281.         return $this->organizer;
  282.     }
  283.     public function setOrganizer(?Organizer $organizer): self
  284.     {
  285.         $this->organizer $organizer;
  286.         return $this;
  287.     }
  288.     public function getIsCreatedByAdmin(): ?bool
  289.     {
  290.         return $this->isCreatedByAdmin;
  291.     }
  292.     public function setIsCreatedByAdmin(bool $isCreatedByAdmin): self
  293.     {
  294.         $this->isCreatedByAdmin $isCreatedByAdmin;
  295.         return $this;
  296.     }
  297.     public function getPlace(): ?Place
  298.     {
  299.         return $this->place;
  300.     }
  301.     public function setPlace(?Place $place): self
  302.     {
  303.         $this->place $place;
  304.         return $this;
  305.     }
  306.     public function getName(): ?string
  307.     {
  308.         return $this->name;
  309.     }
  310.     public function setName(string $name): self
  311.     {
  312.         $this->name $name;
  313.         return $this;
  314.     }
  315.     public function getPrice(): ?string
  316.     {
  317.         return $this->price;
  318.     }
  319.     public function setPrice(?string $price): self
  320.     {
  321.         $this->price $price;
  322.         return $this;
  323.     }
  324.     public function getPriceDescription(): ?string
  325.     {
  326.         return $this->priceDescription;
  327.     }
  328.     public function setPriceDescription(?string $priceDescription): self
  329.     {
  330.         $this->priceDescription $priceDescription;
  331.         return $this;
  332.     }
  333.     public function getShortDescription(): ?string
  334.     {
  335.         return $this->shortDescription;
  336.     }
  337.     public function setShortDescription(?string $shortDescription): self
  338.     {
  339.         $this->shortDescription $shortDescription;
  340.         return $this;
  341.     }
  342.     public function getDescription(): ?string
  343.     {
  344.         return $this->description;
  345.     }
  346.     public function setDescription(?string $description): self
  347.     {
  348.         $this->description $description;
  349.         return $this;
  350.     }
  351.     public function getRequirements(): ?string
  352.     {
  353.         return $this->requirements;
  354.     }
  355.     public function setRequirements(?string $requirements): self
  356.     {
  357.         $this->requirements $requirements;
  358.         return $this;
  359.     }
  360.     public function getPublishedAt(): ?\DateTimeInterface
  361.     {
  362.         return $this->publishedAt;
  363.     }
  364.     public function setPublishedAt(?\DateTimeInterface $publishedAt): self
  365.     {
  366.         $this->publishedAt $publishedAt;
  367.         return $this;
  368.     }
  369.     public function getLength(): ?int
  370.     {
  371.         return $this->length;
  372.     }
  373.     public function setLength(?int $length): self
  374.     {
  375.         $this->length $length;
  376.         return $this;
  377.     }
  378.     public function getState(): ?CourseState
  379.     {
  380.         return $this->state;
  381.     }
  382.     public function setState(?CourseState $state): self
  383.     {
  384.         $this->state $state;
  385.         return $this;
  386.     }
  387.     public function getType(): ?CourseType
  388.     {
  389.         return $this->type;
  390.     }
  391.     public function setType(?CourseType $type): self
  392.     {
  393.         $this->type $type;
  394.         return $this;
  395.     }
  396.     public function getCanCustomize(): ?bool
  397.     {
  398.         return $this->canCustomize;
  399.     }
  400.     public function setCanCustomize(bool $canCustomize): self
  401.     {
  402.         $this->canCustomize $canCustomize;
  403.         return $this;
  404.     }
  405.     public function getIsPreparationForCertification(): ?bool
  406.     {
  407.         return $this->isPreparationForCertification;
  408.     }
  409.     public function setIsPreparationForCertification(bool $isPreparationForCertification): self
  410.     {
  411.         $this->isPreparationForCertification $isPreparationForCertification;
  412.         return $this;
  413.     }
  414.     public function getIsWithCertificate(): ?bool
  415.     {
  416.         return $this->isWithCertificate;
  417.     }
  418.     public function setIsWithCertificate(bool $isWithCertificate): self
  419.     {
  420.         $this->isWithCertificate $isWithCertificate;
  421.         return $this;
  422.     }
  423.     public function getCertificate(): ?Certification
  424.     {
  425.         return $this->certificate;
  426.     }
  427.     public function setCertificate(?Certification $certificate): self
  428.     {
  429.         $this->certificate $certificate;
  430.         return $this;
  431.     }
  432.     public function getFrequency(): ?CourseFrequency
  433.     {
  434.         return $this->frequency;
  435.     }
  436.     public function setFrequency(?CourseFrequency $frequency): self
  437.     {
  438.         $this->frequency $frequency;
  439.         return $this;
  440.     }
  441.     public function getPlaceType(): ?CoursePlaceType
  442.     {
  443.         return $this->placeType;
  444.     }
  445.     public function setPlaceType(?CoursePlaceType $placeType): self
  446.     {
  447.         $this->placeType $placeType;
  448.         return $this;
  449.     }
  450.     public function getCanBuy(): ?bool
  451.     {
  452.         return $this->canBuy;
  453.     }
  454.     public function setCanBuy(bool $canBuy): self
  455.     {
  456.         $this->canBuy $canBuy;
  457.         return $this;
  458.     }
  459.     public function getCanRegister(): ?bool
  460.     {
  461.         return $this->canRegister;
  462.     }
  463.     public function setCanRegister(bool $canRegister): self
  464.     {
  465.         $this->canRegister $canRegister;
  466.         return $this;
  467.     }
  468.     /**
  469.      * @return Collection|CourseReview[]
  470.      */
  471.     public function getReviews(): Collection
  472.     {
  473.         return $this->reviews;
  474.     }
  475.     public function addReview(CourseReview $review): self
  476.     {
  477.         if (!$this->reviews->contains($review)) {
  478.             $this->reviews[] = $review;
  479.             $review->setCourse($this);
  480.         }
  481.         return $this;
  482.     }
  483.     public function removeReview(CourseReview $review): self
  484.     {
  485.         if ($this->reviews->removeElement($review)) {
  486.             // set the owning side to null (unless already changed)
  487.             if ($review->getCourse() === $this) {
  488.                 $review->setCourse(null);
  489.             }
  490.         }
  491.         return $this;
  492.     }
  493.     /**
  494.      * @return Collection|CourseStats[]
  495.      */
  496.     public function getStats(): Collection
  497.     {
  498.         return $this->stats;
  499.     }
  500.     public function addStat(CourseStats $stats): self
  501.     {
  502.         if (!$this->stats->contains($stats)) {
  503.             $this->stats[] = $stats;
  504.             $stats->setCourse($this);
  505.         }
  506.         return $this;
  507.     }
  508.     public function removeStat(CourseStats $review): self
  509.     {
  510.         if ($this->stats->removeElement($review)) {
  511.             // set the owning side to null (unless already changed)
  512.             if ($review->getCourse() === $this) {
  513.                 $review->setCourse(null);
  514.             }
  515.         }
  516.         return $this;
  517.     }
  518.     /**
  519.      * @return Collection|Attribute[]
  520.      */
  521.     public function getAttributes(): Collection
  522.     {
  523.         return $this->attributes;
  524.     }
  525.     public function addAttribute(Attribute $attribute): self
  526.     {
  527.         if (!$this->attributes->contains($attribute)) {
  528.             $this->attributes[] = $attribute;
  529.         }
  530.         return $this;
  531.     }
  532.     public function removeAttribute(Attribute $attribute): self
  533.     {
  534.         $this->attributes->removeElement($attribute);
  535.         return $this;
  536.     }
  537.     /**
  538.      * @return Collection|Lecturer[]
  539.      */
  540.     public function getLecturers(): Collection
  541.     {
  542.         return $this->lecturers;
  543.     }
  544.     public function addLecturer(Lecturer $lecturer): self
  545.     {
  546.         if (!$this->lecturers->contains($lecturer)) {
  547.             $this->lecturers[] = $lecturer;
  548.         }
  549.         return $this;
  550.     }
  551.     public function removeLecturer(Lecturer $lecturer): self
  552.     {
  553.         $this->lecturers->removeElement($lecturer);
  554.         return $this;
  555.     }
  556.     /**
  557.      * @return Collection|Tag[]
  558.      */
  559.     public function getTags(): Collection
  560.     {
  561.         return $this->tags;
  562.     }
  563.     public function addTag(Tag $tag): self
  564.     {
  565.         if (!$this->tags->contains($tag)) {
  566.             $this->tags[] = $tag;
  567.         }
  568.         return $this;
  569.     }
  570.     public function removeTag(Tag $tag): self
  571.     {
  572.         $this->tags->removeElement($tag);
  573.         return $this;
  574.     }
  575.     /**
  576.      * @return Collection|Promoter[]
  577.      */
  578.     public function getPromoters(): Collection
  579.     {
  580.         return $this->promoters;
  581.     }
  582.     public function addPromoter(Promoter $promoter): self
  583.     {
  584.         if (!$this->promoters->contains($promoter)) {
  585.             $this->promoters[] = $promoter;
  586.         }
  587.         return $this;
  588.     }
  589.     public function removePromoter(Promoter $promoter): self
  590.     {
  591.         $this->promoters->removeElement($promoter);
  592.         return $this;
  593.     }
  594.     public function getTopic(): ?CourseTopic
  595.     {
  596.         return $this->topic;
  597.     }
  598.     public function setTopic(?CourseTopic $topic): self
  599.     {
  600.         $this->topic $topic;
  601.         return $this;
  602.     }
  603.     public function getEmail(): ?string
  604.     {
  605.         return $this->email;
  606.     }
  607.     public function setEmail(string $email): self
  608.     {
  609.         $this->email $email;
  610.         return $this;
  611.     }
  612.     public function getCanPaid(): ?bool
  613.     {
  614.         return $this->canPaid;
  615.     }
  616.     public function setCanPaid(?bool $canPaid): self
  617.     {
  618.         $this->canPaid $canPaid;
  619.         return $this;
  620.     }
  621.     /**
  622.      * @return Collection|DayInWeek[]
  623.      */
  624.     public function getDayInWeeks(): Collection
  625.     {
  626.         return $this->dayInWeeks;
  627.     }
  628.     public function addDayInWeek(DayInWeek $dayInWeek): self
  629.     {
  630.         if (!$this->dayInWeeks->contains($dayInWeek)) {
  631.             $this->dayInWeeks[] = $dayInWeek;
  632.         }
  633.         return $this;
  634.     }
  635.     public function removeDayInWeek(DayInWeek $dayInWeek): self
  636.     {
  637.         $this->dayInWeeks->removeElement($dayInWeek);
  638.         return $this;
  639.     }
  640.     public function getFrequencyText(): ?string
  641.     {
  642.         return $this->frequencyText;
  643.     }
  644.     public function setFrequencyText(?string $frequencyText): self
  645.     {
  646.         $this->frequencyText $frequencyText;
  647.         return $this;
  648.     }
  649.     public function getLessonStart(): ?\DateTimeInterface
  650.     {
  651.         return $this->lessonStart;
  652.     }
  653.     public function setLessonStart(?\DateTimeInterface $lessonStart): self
  654.     {
  655.         $this->lessonStart $lessonStart;
  656.         return $this;
  657.     }
  658.     public function getLessonEnd(): ?\DateTimeInterface
  659.     {
  660.         return $this->lessonEnd;
  661.     }
  662.     public function setLessonEnd(?\DateTimeInterface $lessonEnd): self
  663.     {
  664.         $this->lessonEnd $lessonEnd;
  665.         return $this;
  666.     }
  667.     public function getLengthType(): ?CourseLength
  668.     {
  669.         return $this->lengthType;
  670.     }
  671.     public function setLengthType(?CourseLength $lengthType): self
  672.     {
  673.         $this->lengthType $lengthType;
  674.         return $this;
  675.     }
  676.     public function getProgressLevel(): ?CourseProgressLevel
  677.     {
  678.         return $this->progressLevel;
  679.     }
  680.     public function setProgressLevel(?CourseProgressLevel $progressLevel): self
  681.     {
  682.         $this->progressLevel $progressLevel;
  683.         return $this;
  684.     }
  685.     public function getLanguageLevelInput(): ?LanguageLevel
  686.     {
  687.         return $this->languageLevelInput;
  688.     }
  689.     public function setLanguageLevelInput(?LanguageLevel $languageLevel): self
  690.     {
  691.         $this->languageLevelInput $languageLevel;
  692.         return $this;
  693.     }
  694.     public function getLanguageLevelOutput(): ?LanguageLevel
  695.     {
  696.         return $this->languageLevelOutput;
  697.     }
  698.     public function setLanguageLevelOutput(?LanguageLevel $languageLevel): self
  699.     {
  700.         $this->languageLevelOutput $languageLevel;
  701.         return $this;
  702.     }
  703.     public function getIsConfirmationOfParticipation(): ?bool
  704.     {
  705.         return $this->isConfirmationOfParticipation;
  706.     }
  707.     public function setIsConfirmationOfParticipation(?bool $isConfirmationOfParticipation): self
  708.     {
  709.         $this->isConfirmationOfParticipation $isConfirmationOfParticipation;
  710.         return $this;
  711.     }
  712.     public function getCertificationPriceNotIncluded(): ?bool
  713.     {
  714.         return $this->certificationPriceNotIncluded;
  715.     }
  716.     public function setCertificationPriceNotIncluded(?bool $certificationPriceNotIncluded): self
  717.     {
  718.         $this->certificationPriceNotIncluded $certificationPriceNotIncluded;
  719.         return $this;
  720.     }
  721.     public function getCertificationPrice(): ?string
  722.     {
  723.         return $this->certificationPrice;
  724.     }
  725.     public function setCertificationPrice(?string $certificationPrice): self
  726.     {
  727.         $this->certificationPrice $certificationPrice;
  728.         return $this;
  729.     }
  730.     public function getConfirmationName(): ?string
  731.     {
  732.         return $this->confirmationName;
  733.     }
  734.     public function setConfirmationName(?string $confirmationName): self
  735.     {
  736.         $this->confirmationName $confirmationName;
  737.         return $this;
  738.     }
  739.     /**
  740.      * @Assert\Callback
  741.      */
  742.     public function validate(ExecutionContextInterface $context$payload)
  743.     {
  744. //        if (!empty($this->start) && $this->start < date_create_from_format('Y-m-d','2021-01-01')) {
  745. //            $context->buildViolation('Minimální datum zahájení je 1. 1. 2021')
  746. //                ->atPath('start')
  747. //                ->addViolation();
  748. //        }
  749. //
  750. //        if ($this->end > date_create_from_format('Y-m-d','2031-12-31')) {
  751. //            $context->buildViolation('Maximální datum ukončení je 31. 12. 2031')
  752. //                ->atPath('end')
  753. //                ->addViolation();
  754. //        }
  755. //
  756. //        if ($this->registrationStart > $this->registrationEnd) {
  757. //            $context->buildViolation('Datum registrace musí být menší než konec registrace')
  758. //                ->atPath('registrationStart')
  759. //                ->addViolation();
  760. //        }
  761. //
  762. //        if ($this->start > $this->end) {
  763. //            $context->buildViolation('Datum zahájení musí být menší než konec')
  764. //                ->atPath('start')
  765. //                ->addViolation();
  766. //        }
  767. //
  768. //        if ($this->registrationEnd > $this->end) {
  769. //            $context->buildViolation('Datum ukončení registrace musí být před Datem ukončení kurzu.')
  770. //                ->atPath('registrationEnd')
  771. //                ->addViolation();
  772. //        }
  773. //
  774. //        if ($this->publishedAt > $this->end) {
  775. //            $context->buildViolation('Datum publikování musí být před Datem ukončení kurzu.')
  776. //                ->atPath('publishedAt')
  777. //                ->addViolation();
  778. //        }
  779. //
  780. //        if ($this->minimumNumberOfPersons > $this->maximumNumberOfPersons) {
  781. //            $context->buildViolation('Počet lidí minimální musí být menší počet lidí maximální.')
  782. //                ->atPath('minimumNumberOfPersons')
  783. //                ->addViolation();
  784. //        }
  785.     }
  786.     public function getCity(): ?City
  787.     {
  788.         return $this->city;
  789.     }
  790.     public function setCity(?City $city): self
  791.     {
  792.         $this->city $city;
  793.         return $this;
  794.     }
  795.     public function getUrl(): ?string
  796.     {
  797.         return $this->url;
  798.     }
  799.     public function setUrl(?string $url): self
  800.     {
  801.         $this->url $url;
  802.         return $this;
  803.     }
  804.     public function getIsRecommended(): ?bool
  805.     {
  806.         return $this->isRecommended;
  807.     }
  808.     public function setIsRecommended(?bool $isRecommended): self
  809.     {
  810.         $this->isRecommended $isRecommended;
  811.         return $this;
  812.     }
  813.     public function getRating(): ?float
  814.     {
  815.         return $this->rating;
  816.     }
  817.     public function setRating(float $rating): self
  818.     {
  819.         $this->rating $rating;
  820.         return $this;
  821.     }
  822.     public function getIsNativeSpeaker(): ?bool
  823.     {
  824.         return $this->isNativeSpeaker;
  825.     }
  826.     public function setIsNativeSpeaker(bool $isNativeSpeaker): self
  827.     {
  828.         $this->isNativeSpeaker $isNativeSpeaker;
  829.         return $this;
  830.     }
  831.     /**
  832.      * @return false
  833.      */
  834.     public function getIsCustomized(): bool
  835.     {
  836.         return $this->isCustomized;
  837.     }
  838.     /**
  839.      * @param false $isCustomized
  840.      */
  841.     public function setIsCustomized(bool $isCustomized): void
  842.     {
  843.         $this->isCustomized $isCustomized;
  844.     }
  845.     public function getTeachingType(): ?TeachingType
  846.     {
  847.         return $this->teachingType;
  848.     }
  849.     public function setTeachingType(?TeachingType $teachingType): self
  850.     {
  851.         $this->teachingType $teachingType;
  852.         return $this;
  853.     }
  854.     public function getOnlyForAdults(): ?bool
  855.     {
  856.         return $this->onlyForAdults;
  857.     }
  858.     public function setOnlyForAdults(?bool $onlyForAdults): self
  859.     {
  860.         $this->onlyForAdults $onlyForAdults;
  861.         return $this;
  862.     }
  863.     public function getLastStep(): ?int
  864.     {
  865.         return $this->lastStep;
  866.     }
  867.     public function setLastStep(int $lastStep): self
  868.     {
  869.         if ($lastStep 7) {
  870.             $lastStep 7;
  871.         }
  872.         $this->lastStep $lastStep;
  873.         return $this;
  874.     }
  875.     /**
  876.      * @return Collection|CourseTerm[]
  877.      */
  878.     public function getTerms(): Collection
  879.     {
  880.         return $this->terms;
  881.     }
  882.     public function addTerm(CourseTerm $term): self
  883.     {
  884.         if (!$this->terms->contains($term)) {
  885.             $this->terms[] = $term;
  886.             $term->setCourse($this);
  887.         }
  888.         return $this;
  889.     }
  890.     public function removeTerm(CourseTerm $term): self
  891.     {
  892.         if ($this->terms->removeElement($term)) {
  893.             // set the owning side to null (unless already changed)
  894.             if ($term->getCourse() === $this) {
  895.                 $term->setCourse(null);
  896.             }
  897.         }
  898.         return $this;
  899.     }
  900.     public function getPlaceDescription(): ?string
  901.     {
  902.         return $this->placeDescription;
  903.     }
  904.     public function setPlaceDescription(?string $placeDescription): self
  905.     {
  906.         $this->placeDescription $placeDescription;
  907.         return $this;
  908.     }
  909.     /**
  910.      * @return mixed
  911.      */
  912.     public function getRetrainingType()
  913.     {
  914.         return $this->retrainingType;
  915.     }
  916.     /**
  917.      * @param mixed $retrainingType
  918.      */
  919.     public function setRetrainingType($retrainingType): void
  920.     {
  921.         $this->retrainingType $retrainingType;
  922.     }
  923.     /**
  924.      * @return mixed
  925.      */
  926.     public function getLatitude()
  927.     {
  928.         return $this->latitude;
  929.     }
  930.     /**
  931.      * @param mixed $latitude
  932.      */
  933.     public function setLatitude($latitude): void
  934.     {
  935.         $this->latitude $latitude;
  936.     }
  937.     /**
  938.      * @return mixed
  939.      */
  940.     public function getLongitude()
  941.     {
  942.         return $this->longitude;
  943.     }
  944.     /**
  945.      * @param mixed $longitude
  946.      */
  947.     public function setLongitude($longitude): void
  948.     {
  949.         $this->longitude $longitude;
  950.     }
  951.     /**
  952.      * @return mixed
  953.      */
  954.     public function getCode()
  955.     {
  956.         return $this->code;
  957.     }
  958.     /**
  959.      * @param mixed $code
  960.      */
  961.     public function setCode($code): void
  962.     {
  963.         $this->code $code;
  964.     }
  965.     public function getExternalCode()
  966.     {
  967.         return str_replace($this->getOrganizer()->getId() . '_'''$this->code);
  968.     }
  969.     public function getTargetGroup(): ?TargetGroup
  970.     {
  971.         return $this->targetGroup;
  972.     }
  973.     public function setTargetGroup(?TargetGroup $targetGroup): self
  974.     {
  975.         $this->targetGroup $targetGroup;
  976.         return $this;
  977.     }
  978.     /**
  979.      * @return mixed
  980.      */
  981.     public function getEndAt()
  982.     {
  983.         return $this->endAt;
  984.     }
  985.     /**
  986.      * @param mixed $endAt
  987.      */
  988.     public function setEndAt($endAt): void
  989.     {
  990.         $this->endAt $endAt;
  991.     }
  992.     public function getControlEndAt()
  993.     {
  994.         if($this->terms->isEmpty()) {
  995.             return $this->endAt;
  996.         }
  997.         $latestTerm $this->getLatestTerm();
  998.         return $latestTerm->getEnd();
  999.     }
  1000.     public function getLatestTerm()
  1001.     {
  1002.         // Vytvořte Criteria objekt pro řazení podle data sestupně
  1003.         $criteria Criteria::create()->orderBy(['end' => 'DESC'])->setMaxResults(1);
  1004.         // Použijte Criteria na filtrování podřízených entit
  1005.         $latestSubEntity $this->terms->matching($criteria)->first();
  1006.         return $latestSubEntity;
  1007.     }
  1008. }