src/Entity/Course.php line 11
<?php
namespace App\Entity;
use App\Repository\CourseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CourseRepository::class)]
class Course
{
#[ORM\Id]
#[ORM\Column(length: 255)]
private ?string $course_id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\OneToMany(mappedBy: 'course', targetEntity: Character::class)]
private Collection $characters;
public function __construct()
{
$this->characters = new ArrayCollection();
}
public function getCourseId(): ?string
{
return $this->course_id;
}
public function setCourseId(string $course_id): self
{
$this->course_id = $course_id;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return Collection<string, Character>
*/
public function getCharacters(): Collection
{
return $this->characters;
}
public function addCharacter(Character $character): self
{
if (!$this->characters->contains($character)) {
$this->characters->add($character);
$character->setCourse($this);
}
return $this;
}
public function removeCharacter(Character $character): self
{
if ($this->characters->removeElement($character)) {
// set the owning side to null (unless already changed)
if ($character->getCourse() === $this) {
$character->setCourse(null);
}
}
return $this;
}
public function __toString(): string
{
return "$this->course_id";
}
}