src/Entity/CourseType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CourseTypeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. #[ORM\Entity(repositoryClass: CourseTypeRepository::class)]
  10. class CourseType
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     #[Groups(["show_course", "list_courses"])]
  16.     private ?int $id = null;
  17.     #[ORM\OneToMany(mappedBy: 'courseType', targetEntity: Course::class)]
  18.     private Collection $courses;
  19.     #[ORM\Column(length: 255)]
  20.     #[Groups(["show_course", "list_courses"])]
  21.     private ?string $title = null;
  22.     #[ORM\Column(type: Types::TEXT)]
  23.     #[Groups(["show_course"])]
  24.     private ?string $description = null;
  25.     public function __construct()
  26.     {
  27.         $this->courses = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     /**
  34.      * @return Collection<int, Course>
  35.      */
  36.   /*   public function getCourses(): Collection
  37.     {
  38.         return $this->courses;
  39.     } */
  40.     public function addCourse(Course $course): self
  41.     {
  42.         if (!$this->courses->contains($course)) {
  43.             $this->courses->add($course);
  44.             $course->setCourseType($this);
  45.         }
  46.         return $this;
  47.     }
  48.     public function removeCourse(Course $course): self
  49.     {
  50.         if ($this->courses->removeElement($course)) {
  51.             // set the owning side to null (unless already changed)
  52.             if ($course->getCourseType() === $this) {
  53.                 $course->setCourseType(null);
  54.             }
  55.         }
  56.         return $this;
  57.     }
  58.     public function getTitle(): ?string
  59.     {
  60.         return $this->title;
  61.     }
  62.     public function setTitle(string $title): self
  63.     {
  64.         $this->title = $title;
  65.         return $this;
  66.     }
  67.     public function getDescription(): ?string
  68.     {
  69.         return $this->description;
  70.     }
  71.     public function setDescription(string $description): self
  72.     {
  73.         $this->description = $description;
  74.         return $this;
  75.     }
  76. }