src/Entity/TypeEnseignement.php line 20

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use App\Repository\TypeEnseignementRepository;
  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. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassTypeEnseignementRepository::class)]
  12. #[ApiResource(
  13.     operations: [
  14.         new GetCollection()
  15.     ]
  16. )]
  17. class TypeEnseignement
  18. {
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     #[Groups(['read:user:item'])]
  23.     private ?int $id null;
  24.     #[ORM\Column(length255)]
  25.     #[Assert\NotBlank(message"Ne peut ĂȘtre vide !")]
  26.     #[Assert\NotNull(message"Ne peut ĂȘtre nul !")]
  27.     #[Groups(['read:user:item'])]
  28.     private ?string $name null;
  29.     #[ORM\Column(length255)]
  30.     #[Groups(['read:user:item'])]
  31.     private ?string $slug null;
  32.     #[ORM\OneToMany(mappedBy'typeEnseignement'targetEntityFiliere::class, orphanRemovaltrue)]
  33.     private Collection $filieres;
  34.     public function __construct()
  35.     {
  36.         $this->filieres = 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, Filiere>
  62.      */
  63.     public function getFilieres(): Collection
  64.     {
  65.         return $this->filieres;
  66.     }
  67.     public function addFiliere(Filiere $filiere): self
  68.     {
  69.         if (!$this->filieres->contains($filiere)) {
  70.             $this->filieres->add($filiere);
  71.             $filiere->setTypeEnseignement($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeFiliere(Filiere $filiere): self
  76.     {
  77.         if ($this->filieres->removeElement($filiere)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($filiere->getTypeEnseignement() === $this) {
  80.                 $filiere->setTypeEnseignement(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85. }