src/Entity/CourseLanguage.php line 13
<?php
namespace App\Entity;
use App\Repository\CourseLanguageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: CourseLanguageRepository::class)]
class CourseLanguage
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Column(type: 'uuid', unique: true)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 191, unique: true)]
#[Gedmo\Slug(fields: ['name'])]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'language', targetEntity: Course::class)]
private Collection $courses;
public function __construct()
{
$this->courses = new ArrayCollection();
}
public function __toString() {
return $this->name;
}
public function getId(): ?Uuid
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @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->setLanguage($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->getLanguage() === $this) {
$course->setLanguage(null);
}
}
return $this;
}
}