src/Entity/CourseEducation.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CourseEducationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Uid\Uuid;
  9. #[ORM\Entity(repositoryClassCourseEducationRepository::class)]
  10. class CourseEducation
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  14.     #[ORM\Column(type'uuid'uniquetrue)]
  15.     #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
  16.     private ?Uuid $id null;
  17.     
  18.     #[ORM\Column(length255)]
  19.     private ?string $name null;
  20.     
  21.     #[ORM\Column(length191uniquetrue)]
  22.     #[Gedmo\Slug(fields: ['name'])]
  23.     private ?string $slug null;
  24.     #[ORM\ManyToMany(targetEntityCourse::class, mappedBy'educations')]
  25.     private Collection $courses;
  26.     public function __construct()
  27.     {
  28.         $this->courses = new ArrayCollection();
  29.     }
  30.     
  31.     public function __toString() {
  32.         return $this->name;
  33.     }
  34.     
  35.     public function getId(): ?Uuid
  36.     {
  37.         return $this->id;
  38.     }
  39.     
  40.     public function getName(): ?string
  41.     {
  42.         return $this->name;
  43.     }
  44.     
  45.     public function setName(string $name): self
  46.     {
  47.         $this->name $name;
  48.         
  49.         return $this;
  50.     }
  51.     
  52.     public function getSlug(): ?string
  53.     {
  54.         return $this->slug;
  55.     }
  56.     
  57.     public function setSlug(string $slug): self
  58.     {
  59.         $this->slug $slug;
  60.         
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, Course>
  65.      */
  66.     public function getCourses(): Collection
  67.     {
  68.         return $this->courses;
  69.     }
  70.     public function addCourse(Course $course): self
  71.     {
  72.         if (!$this->courses->contains($course)) {
  73.             $this->courses->add($course);
  74.             $course->addEducation($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeCourse(Course $course): self
  79.     {
  80.         if ($this->courses->removeElement($course)) {
  81.             $course->removeEducation($this);
  82.         }
  83.         return $this;
  84.     }
  85. }