<?php
namespace App\Entity;
use App\Repository\CourseTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: CourseTypeRepository::class)]
class CourseType
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(["show_course", "list_courses"])]
private ?int $id = null;
#[ORM\OneToMany(mappedBy: 'courseType', targetEntity: Course::class)]
private Collection $courses;
#[ORM\Column(length: 255)]
#[Groups(["show_course", "list_courses"])]
private ?string $title = null;
#[ORM\Column(type: Types::TEXT)]
#[Groups(["show_course"])]
private ?string $description = null;
public function __construct()
{
$this->courses = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, Course>
*/
/* public function getCourses(): Collection
{
return $this->courses;
} */
public function addCourse(Course $course): self
{
if (!$this->courses->contains($course)) {
$this->courses->add($course);
$course->setCourseType($this);
}
return $this;
}
public function removeCourse(Course $course): self
{
if ($this->courses->removeElement($course)) {
// set the owning side to null (unless already changed)
if ($course->getCourseType() === $this) {
$course->setCourseType(null);
}
}
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
}