src/Entity/SpeakerCourse.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SpeakerCourseRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass=SpeakerCourseRepository::class)
  10.  */
  11. class SpeakerCourse
  12. {
  13.     use RemoveImageTrait;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity=Speaker::class, inversedBy="courses")
  22.      * @ORM\JoinColumn(nullable=false)
  23.      * @Assert\NotBlank()
  24.      */
  25.     private $speaker;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      * @Assert\NotBlank()
  29.      */
  30.     private $name;
  31.     /**
  32.      * @ORM\ManyToMany(targetEntity=Category::class)
  33.      */
  34.     private $categories;
  35.     /**
  36.      * @ORM\Column(type="text")
  37.      * @Assert\NotBlank()
  38.      */
  39.     private $shortDescription;
  40.     /**
  41.      * @ORM\Column(type="integer")
  42.      */
  43.     private $price 0;
  44.     /**
  45.      * @ORM\Column(type="integer")
  46.      */
  47.     private $position 0;
  48.     /**
  49.      * @ORM\Column(type="boolean")
  50.      */
  51.     private $enabled false;
  52.     /**
  53.      * @ORM\Column(type="datetime", nullable=true)
  54.      */
  55.     private $publishedDate;
  56.     /**
  57.      * @ORM\ManyToMany(targetEntity=User::class, inversedBy="courses")
  58.      */
  59.     private $participants;
  60.     /**
  61.      * @ORM\ManyToOne(targetEntity=MediaObject::class, cascade={"persist", "remove"})
  62.      */
  63.     private $thumbnailMediaFile;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  66.      */
  67.     private $videoMediaFile;
  68.     public function __construct()
  69.     {
  70.         $this->categories = new ArrayCollection();
  71.         $this->participants = new ArrayCollection();
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getSpeaker(): ?Speaker
  78.     {
  79.         return $this->speaker;
  80.     }
  81.     public function setSpeaker(?Speaker $speaker): self
  82.     {
  83.         $this->speaker $speaker;
  84.         return $this;
  85.     }
  86.     public function getVideo(): ?string
  87.     {
  88.         return (string) $this->getVideoMediaFile();
  89.     }
  90.     public function getThumbnail(): ?string
  91.     {
  92.         return (string) $this->getThumbnailMediaFile();
  93.     }
  94.     public function getName(): ?string
  95.     {
  96.         return $this->name;
  97.     }
  98.     public function setName(string $name): self
  99.     {
  100.         $this->name $name;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection|Category[]
  105.      */
  106.     public function getCategories(): Collection
  107.     {
  108.         return $this->categories;
  109.     }
  110.     public function addCategory(Category $category): self
  111.     {
  112.         if (!$this->categories->contains($category)) {
  113.             $this->categories[] = $category;
  114.         }
  115.         return $this;
  116.     }
  117.     public function removeCategory(Category $category): self
  118.     {
  119.         $this->categories->removeElement($category);
  120.         return $this;
  121.     }
  122.     public function getShortDescription(): ?string
  123.     {
  124.         return $this->shortDescription;
  125.     }
  126.     public function setShortDescription(string $shortDescription): self
  127.     {
  128.         $this->shortDescription $shortDescription;
  129.         return $this;
  130.     }
  131.     public function getPrice(): ?int
  132.     {
  133.         return $this->price;
  134.     }
  135.     public function setPrice(?int $price): self
  136.     {
  137.         $this->price = (int) $price;
  138.         return $this;
  139.     }
  140.     public function getPosition(): ?int
  141.     {
  142.         return $this->position;
  143.     }
  144.     public function setPosition(int $position): self
  145.     {
  146.         $this->position $position;
  147.         return $this;
  148.     }
  149.     public function getEnabled(): ?bool
  150.     {
  151.         return $this->enabled;
  152.     }
  153.     public function setEnabled(bool $enabled): self
  154.     {
  155.         $this->enabled $enabled;
  156.         if ($this->enabled) {
  157.             $this->setPublishedDate(new \DateTime());
  158.         }
  159.         return $this;
  160.     }
  161.     public function getPublishedDate(): ?\DateTimeInterface
  162.     {
  163.         return $this->publishedDate;
  164.     }
  165.     public function setPublishedDate(?\DateTimeInterface $publishedDate): self
  166.     {
  167.         $this->publishedDate $publishedDate;
  168.         return $this;
  169.     }
  170.     /**
  171.      * @return Collection<int, User>
  172.      */
  173.     public function getParticipants(): Collection
  174.     {
  175.         return $this->participants;
  176.     }
  177.     public function addParticipant(User $participant): self
  178.     {
  179.         if (!$this->participants->contains($participant)) {
  180.             $this->participants[] = $participant;
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeParticipant(User $participant): self
  185.     {
  186.         $this->participants->removeElement($participant);
  187.         return $this;
  188.     }
  189.     public function __toString()
  190.     {
  191.         return $this->getName();
  192.     }
  193.     public function getThumbnailMediaFile(): ?MediaObject
  194.     {
  195.         return $this->thumbnailMediaFile;
  196.     }
  197.     public function setThumbnailMediaFile(?MediaObject $thumbnailMediaFile): self
  198.     {
  199.         $this->thumbnailMediaFile $thumbnailMediaFile;
  200.         return $this;
  201.     }
  202.     public function getVideoMediaFile(): ?MediaObject
  203.     {
  204.         return $this->videoMediaFile;
  205.     }
  206.     public function setVideoMediaFile(?MediaObject $videoMediaFile): self
  207.     {
  208.         $this->videoMediaFile $videoMediaFile;
  209.         return $this;
  210.     }
  211. }