src/Entity/Age.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AgeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassAgeRepository::class)]
  8. class Age
  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'ages')]
  19.     private $courses;
  20.     public function __toString()
  21.     {
  22.         return $this->name;
  23.     }
  24.     public function __construct()
  25.     {
  26.         $this->courses = new ArrayCollection();
  27.     }
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getName(): ?string
  33.     {
  34.         return $this->name;
  35.     }
  36.     public function setName(string $name): self
  37.     {
  38.         $this->name $name;
  39.         return $this;
  40.     }
  41.     public function getSlug(): ?string
  42.     {
  43.         return $this->slug;
  44.     }
  45.     public function setSlug(string $slug): self
  46.     {
  47.         $this->slug $slug;
  48.         return $this;
  49.     }
  50.     /**
  51.      * @return Collection|Course[]
  52.      */
  53.     public function getCourses(): Collection
  54.     {
  55.         return $this->courses;
  56.     }
  57.     public function addCourse(Course $course): self
  58.     {
  59.         if (!$this->courses->contains($course)) {
  60.             $this->courses[] = $course;
  61.             $course->addAge($this);
  62.         }
  63.         return $this;
  64.     }
  65.     public function removeCourse(Course $course): self
  66.     {
  67.         if ($this->courses->removeElement($course)) {
  68.             $course->removeAge($this);
  69.         }
  70.         return $this;
  71.     }
  72. }