src/Entity/Language.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LanguageRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassLanguageRepository::class)]
  8. class Language
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'string'length255)]
  15.     private $name;
  16.     #[ORM\Column(type'string'length255)]
  17.     private $slug;
  18.     #[ORM\ManyToMany(targetEntityCourse::class, mappedBy'languages')]
  19.     private $courses;
  20.     #[ORM\ManyToMany(targetEntityUser::class, mappedBy'languages')]
  21.     private $users;
  22.     public function __toString()
  23.     {
  24.         return $this->name;
  25.     }
  26.     public function __construct()
  27.     {
  28.         $this->courses = new ArrayCollection();
  29.         $this->users = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getName(): ?string
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function setName(string $name): self
  40.     {
  41.         $this->name $name;
  42.         return $this;
  43.     }
  44.     public function getSlug(): ?string
  45.     {
  46.         return $this->slug;
  47.     }
  48.     public function setSlug(string $slug): self
  49.     {
  50.         $this->slug $slug;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @return Collection|Course[]
  55.      */
  56.     public function getCourses(): Collection
  57.     {
  58.         return $this->courses;
  59.     }
  60.     public function addCourse(Course $course): self
  61.     {
  62.         if (!$this->courses->contains($course)) {
  63.             $this->courses[] = $course;
  64.             $course->addLanguage($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeCourse(Course $course): self
  69.     {
  70.         if ($this->courses->removeElement($course)) {
  71.             $course->removeLanguage($this);
  72.         }
  73.         return $this;
  74.     }
  75.     /**
  76.      * @return Collection|User[]
  77.      */
  78.     public function getUsers(): Collection
  79.     {
  80.         return $this->users;
  81.     }
  82.     public function addUser(User $user): self
  83.     {
  84.         if (!$this->users->contains($user)) {
  85.             $this->users[] = $user;
  86.             $user->addLanguage($this);
  87.         }
  88.         return $this;
  89.     }
  90.     public function removeUser(User $user): self
  91.     {
  92.         if ($this->users->removeElement($user)) {
  93.             $user->removeLanguage($this);
  94.         }
  95.         return $this;
  96.     }
  97. }