src/Entity/Course.php line 11

  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\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCourseRepository::class)]
  8. class Course
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\Column(length255)]
  12.     private ?string $course_id null;
  13.     #[ORM\Column(length255)]
  14.     private ?string $title null;
  15.     #[ORM\OneToMany(mappedBy'course'targetEntityCharacter::class)]
  16.     private Collection $characters;
  17.     public function __construct()
  18.     {
  19.         $this->characters = new ArrayCollection();
  20.     }
  21.     public function getCourseId(): ?string
  22.     {
  23.         return $this->course_id;
  24.     }
  25.     public function setCourseId(string $course_id): self
  26.     {
  27.         $this->course_id $course_id;
  28.         return $this;
  29.     }
  30.     public function getTitle(): ?string
  31.     {
  32.         return $this->title;
  33.     }
  34.     public function setTitle(string $title): self
  35.     {
  36.         $this->title $title;
  37.         return $this;
  38.     }
  39.     /**
  40.      * @return Collection<string, Character>
  41.      */
  42.     public function getCharacters(): Collection
  43.     {
  44.         return $this->characters;
  45.     }
  46.     public function addCharacter(Character $character): self
  47.     {
  48.         if (!$this->characters->contains($character)) {
  49.             $this->characters->add($character);
  50.             $character->setCourse($this);
  51.         }
  52.         return $this;
  53.     }
  54.     public function removeCharacter(Character $character): self
  55.     {
  56.         if ($this->characters->removeElement($character)) {
  57.             // set the owning side to null (unless already changed)
  58.             if ($character->getCourse() === $this) {
  59.                 $character->setCourse(null);
  60.             }
  61.         }
  62.         return $this;
  63.     }
  64.     public function __toString(): string
  65.     {
  66.         return "$this->course_id";
  67.     }
  68. }