src/Entity/Classe.php line 32

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  4. use ApiPlatform\Metadata\ApiFilter;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use App\Repository\ClasseRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. #[ORM\Entity(repositoryClassClasseRepository::class)]
  14. #[
  15.     ApiResource(
  16.         operations: [
  17.             new GetCollection(
  18.                 normalizationContext: ['groups' => ['read:classe:collection']]
  19.             )
  20.         ]
  21.     ),
  22.     ApiFilter(SearchFilter::class, properties: [
  23.         'specialite' => 'exact',
  24.         'specialite.filiere' => 'exact',
  25.         'sousSysteme' => 'exact',
  26.     ])
  27. ]
  28. class Classe
  29. {
  30.     #[ORM\Id]
  31.     #[ORM\GeneratedValue]
  32.     #[ORM\Column]
  33.     #[Groups(['read:classe:collection''read:user:item''read:evaluation:collection'])]
  34.     private ?int $id null;
  35.     #[ORM\ManyToOne(inversedBy'classes')]
  36.     #[Groups(['read:user:item'])]
  37.     private ?Specialite $specialite null;
  38.     #[ORM\Column(length255)]
  39.     #[Assert\NotBlank(message"Le nom de classe ne peut ĂȘtre vide !")]
  40.     #[Assert\NotNull(message"Le nom de classe ne peut ĂȘtre nul !")]
  41.     #[Groups(['read:classe:collection''read:user:item''read:evaluation:collection'])]
  42.     private ?string $name null;
  43.     #[ORM\Column(length255)]
  44.     #[Groups(['read:classe:collection''read:user:item''read:evaluation:collection'])]
  45.     private ?string $slug null;
  46.     #[ORM\ManyToMany(targetEntityCours::class, mappedBy'classe')]
  47.     private Collection $cours;
  48.     #[ORM\OneToMany(mappedBy'classe'targetEntityEleve::class)]
  49.     private Collection $eleves;
  50.     #[ORM\OneToMany(mappedBy'classe'targetEntityExam::class)]
  51.     private Collection $exams;
  52.     #[ORM\ManyToOne(inversedBy'classes')]
  53.     #[Groups(['read:classe:collection''read:user:item'])]
  54.     private ?SkillLevel $skillLevel null;
  55.     #[ORM\ManyToOne(inversedBy'classes')]
  56.     #[Groups(['read:classe:collection''read:user:item'])]
  57.     private ?SousSysteme $sousSysteme null;
  58.     #[ORM\ManyToMany(targetEntityEvaluation::class, mappedBy'classes')]
  59.     private Collection $evaluations;
  60.     public function __construct()
  61.     {
  62.         $this->cours = new ArrayCollection();
  63.         $this->eleves = new ArrayCollection();
  64.         $this->exams = new ArrayCollection();
  65.         $this->evaluations = new ArrayCollection();
  66.     }
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getSpecialite(): ?Specialite
  72.     {
  73.         return $this->specialite;
  74.     }
  75.     public function setSpecialite(?Specialite $specialite): self
  76.     {
  77.         $this->specialite $specialite;
  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, Cours>
  100.      */
  101.     public function getCours(): Collection
  102.     {
  103.         return $this->cours;
  104.     }
  105.     public function addCour(Cours $cour): self
  106.     {
  107.         if (!$this->cours->contains($cour)) {
  108.             $this->cours->add($cour);
  109.             $cour->addClasse($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeCour(Cours $cour): self
  114.     {
  115.         if ($this->cours->removeElement($cour)) {
  116.             $cour->removeClasse($this);
  117.         }
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, Eleve>
  122.      */
  123.     public function getEleves(): Collection
  124.     {
  125.         return $this->eleves;
  126.     }
  127.     public function addElefe(Eleve $elefe): self
  128.     {
  129.         if (!$this->eleves->contains($elefe)) {
  130.             $this->eleves->add($elefe);
  131.             $elefe->setClasse($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeElefe(Eleve $elefe): self
  136.     {
  137.         if ($this->eleves->removeElement($elefe)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($elefe->getClasse() === $this) {
  140.                 $elefe->setClasse(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return Collection<int, Exam>
  147.      */
  148.     public function getExams(): Collection
  149.     {
  150.         return $this->exams;
  151.     }
  152.     public function addExam(Exam $exam): self
  153.     {
  154.         if (!$this->exams->contains($exam)) {
  155.             $this->exams->add($exam);
  156.             $exam->setClasse($this);
  157.         }
  158.         return $this;
  159.     }
  160.     public function removeExam(Exam $exam): self
  161.     {
  162.         if ($this->exams->removeElement($exam)) {
  163.             // set the owning side to null (unless already changed)
  164.             if ($exam->getClasse() === $this) {
  165.                 $exam->setClasse(null);
  166.             }
  167.         }
  168.         return $this;
  169.     }
  170.     public function getSkillLevel(): ?SkillLevel
  171.     {
  172.         return $this->skillLevel;
  173.     }
  174.     public function setSkillLevel(?SkillLevel $skillLevel): self
  175.     {
  176.         $this->skillLevel $skillLevel;
  177.         return $this;
  178.     }
  179.     public function getSousSysteme(): ?SousSysteme
  180.     {
  181.         return $this->sousSysteme;
  182.     }
  183.     public function setSousSysteme(?SousSysteme $sousSysteme): self
  184.     {
  185.         $this->sousSysteme $sousSysteme;
  186.         return $this;
  187.     }
  188.     /**
  189.      * @return Collection<int, Evaluation>
  190.      */
  191.     public function getEvaluations(): Collection
  192.     {
  193.         return $this->evaluations;
  194.     }
  195.     public function addEvaluation(Evaluation $evaluation): self
  196.     {
  197.         if (!$this->evaluations->contains($evaluation)) {
  198.             $this->evaluations->add($evaluation);
  199.             $evaluation->addClass($this);
  200.         }
  201.         return $this;
  202.     }
  203.     public function removeEvaluation(Evaluation $evaluation): self
  204.     {
  205.         if ($this->evaluations->removeElement($evaluation)) {
  206.             $evaluation->removeClass($this);
  207.         }
  208.         return $this;
  209.     }
  210. }