src/Entity/Filiere.php line 20

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use App\Repository\FiliereRepository;
  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(repositoryClassFiliereRepository::class)]
  12. #[ApiResource(
  13.     operations: [
  14.         new GetCollection()
  15.     ]
  16. )]
  17. class Filiere
  18. {
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     #[Groups(['read:user:item'])]
  23.     private ?int $id null;
  24.     #[ORM\ManyToMany(targetEntitySousSysteme::class, inversedBy'filieres')]
  25.     private Collection $sousSystemes;
  26.     #[ORM\ManyToOne(inversedBy'filieres')]
  27.     #[ORM\JoinColumn(nullablefalse)]
  28.     #[Groups(['read:user:item'])]
  29.     private ?TypeEnseignement $typeEnseignement null;
  30.     #[ORM\Column(length255)]
  31.     #[Assert\NotBlank(message"Ne peut ĂȘtre vide !")]
  32.     #[Assert\NotNull(message"Ne peut ĂȘtre nul !")]
  33.     #[Groups(['read:user:item'])]
  34.     private ?string $name null;
  35.     #[ORM\Column(length255)]
  36.     #[Groups(['read:user:item'])]
  37.     private ?string $slug null;
  38.     #[ORM\OneToMany(mappedBy'filiere'targetEntitySpecialite::class, orphanRemovaltrue)]
  39.     private Collection $specialites;
  40.     #[ORM\ManyToMany(targetEntityUser::class, mappedBy'filiere')]
  41.     private Collection $users;
  42.     public function __construct()
  43.     {
  44.         $this->sousSystemes = new ArrayCollection();
  45.         $this->specialites = new ArrayCollection();
  46.         $this->users = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     /**
  53.      * @return Collection<int, SousSysteme>
  54.      */
  55.     public function getSousSystemes(): Collection
  56.     {
  57.         return $this->sousSystemes;
  58.     }
  59.     public function addSousSysteme(SousSysteme $sousSysteme): self
  60.     {
  61.         if (!$this->sousSystemes->contains($sousSysteme)) {
  62.             $this->sousSystemes->add($sousSysteme);
  63.         }
  64.         return $this;
  65.     }
  66.     public function removeSousSysteme(SousSysteme $sousSysteme): self
  67.     {
  68.         $this->sousSystemes->removeElement($sousSysteme);
  69.         return $this;
  70.     }
  71.     public function getTypeEnseignement(): ?TypeEnseignement
  72.     {
  73.         return $this->typeEnseignement;
  74.     }
  75.     public function setTypeEnseignement(?TypeEnseignement $typeEnseignement): self
  76.     {
  77.         $this->typeEnseignement $typeEnseignement;
  78.         return $this;
  79.     }
  80.     public function getName(): ?string
  81.     {
  82.         return $this->name;
  83.     }
  84.     public function setName(string $name): self
  85.     {
  86.         $this->name $name;
  87.         return $this;
  88.     }
  89.     public function getSlug(): ?string
  90.     {
  91.         return $this->slug;
  92.     }
  93.     public function setSlug(string $slug): self
  94.     {
  95.         $this->slug $slug;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, Specialite>
  100.      */
  101.     public function getSpecialites(): Collection
  102.     {
  103.         return $this->specialites;
  104.     }
  105.     public function addSpecialite(Specialite $specialite): self
  106.     {
  107.         if (!$this->specialites->contains($specialite)) {
  108.             $this->specialites->add($specialite);
  109.             $specialite->setFiliere($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeSpecialite(Specialite $specialite): self
  114.     {
  115.         if ($this->specialites->removeElement($specialite)) {
  116.             // set the owning side to null (unless already changed)
  117.             if ($specialite->getFiliere() === $this) {
  118.                 $specialite->setFiliere(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     /**
  124.      * @return Collection<int, User>
  125.      */
  126.     public function getUsers(): Collection
  127.     {
  128.         return $this->users;
  129.     }
  130.     public function addUser(User $user): self
  131.     {
  132.         if (!$this->users->contains($user)) {
  133.             $this->users->add($user);
  134.             $user->addFiliere($this);
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeUser(User $user): self
  139.     {
  140.         if ($this->users->removeElement($user)) {
  141.             $user->removeFiliere($this);
  142.         }
  143.         return $this;
  144.     }
  145. }