src/Entity/SkillLevel.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use App\Repository\SkillLevelRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClassSkillLevelRepository::class)]
  11. #[ApiResource(
  12.     operations: [
  13.         new GetCollection()
  14.     ]
  15. )]
  16. class SkillLevel
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     #[Groups(['read:classe:collection''read:user:item'])]
  22.     private ?int $id null;
  23.     #[ORM\Column(length255)]
  24.     #[Groups(['read:classe:collection''read:user:item'])]
  25.     private ?string $name null;
  26.     #[ORM\Column(length255)]
  27.     #[Groups(['read:classe:collection''read:user:item'])]
  28.     private ?string $slug null;
  29.     #[ORM\OneToMany(mappedBy'skillLevel'targetEntityClasse::class)]
  30.     private Collection $classes;
  31.     #[ORM\OneToMany(mappedBy'skillLevel'targetEntityCours::class)]
  32.     private Collection $cours;
  33.     public function __construct()
  34.     {
  35.         $this->classes = new ArrayCollection();
  36.         $this->cours = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName(): ?string
  43.     {
  44.         return $this->name;
  45.     }
  46.     public function setName(string $name): self
  47.     {
  48.         $this->name $name;
  49.         return $this;
  50.     }
  51.     public function getSlug(): ?string
  52.     {
  53.         return $this->slug;
  54.     }
  55.     public function setSlug(string $slug): self
  56.     {
  57.         $this->slug $slug;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, Classe>
  62.      */
  63.     public function getClasses(): Collection
  64.     {
  65.         return $this->classes;
  66.     }
  67.     public function addClass(Classe $class): self
  68.     {
  69.         if (!$this->classes->contains($class)) {
  70.             $this->classes->add($class);
  71.             $class->setSkillLevel($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeClass(Classe $class): self
  76.     {
  77.         if ($this->classes->removeElement($class)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($class->getSkillLevel() === $this) {
  80.                 $class->setSkillLevel(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, Cours>
  87.      */
  88.     public function getCours(): Collection
  89.     {
  90.         return $this->cours;
  91.     }
  92.     public function addCour(Cours $cour): self
  93.     {
  94.         if (!$this->cours->contains($cour)) {
  95.             $this->cours->add($cour);
  96.             $cour->setSkillLevel($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeCour(Cours $cour): self
  101.     {
  102.         if ($this->cours->removeElement($cour)) {
  103.             // set the owning side to null (unless already changed)
  104.             if ($cour->getSkillLevel() === $this) {
  105.                 $cour->setSkillLevel(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110. }