src/Entity/Categorie.php line 38

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Get;
  6. use App\Repository\CategorieRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ORM\Entity(repositoryClassCategorieRepository::class)]
  13. #[ORM\Table(name'categorie')]
  14. #[ORM\Index(columns: ['name'], name'idx_categorie_name')]
  15. #[ApiResource(
  16.     operations: [
  17.         new Get(
  18.             normalizationContext: [
  19.                 'groups' => ['read:category:item''read:category:collection']
  20.             ]
  21.         ),
  22.         new GetCollection(
  23.             normalizationContext: [
  24.                 'groups' => ['read:category:collection']
  25.             ],
  26.             paginationClientItemsPerPagetrue,
  27.             paginationItemsPerPage30,
  28.             paginationMaximumItemsPerPage25,
  29.         ),
  30.     ],
  31.     normalizationContext: [
  32.         'groups' => ['read:category:collection']
  33.     ],
  34. )]
  35. class Categorie
  36. {
  37.     #[ORM\Id]
  38.     #[ORM\GeneratedValue]
  39.     #[ORM\Column]
  40.     #[Groups(['read:course:collection''read:category:collection''read:evaluation:collection'])]
  41.     private ?int $id null;
  42.     #[ORM\Column(length255)]
  43.     #[Groups(['read:course:collection''read:category:collection''read:evaluation:collection'])]
  44.     private ?string $name null;
  45.     #[ORM\Column(length255)]
  46.     #[Groups(['read:course:collection''read:category:collection''read:evaluation:collection'])]
  47.     private ?string $slug null;
  48.     #[ORM\OneToMany(mappedBy'categorie'targetEntityCours::class)]
  49.     private Collection $cours;
  50.     #[ORM\Column(length255nullabletrue)]
  51.     #[Groups(['read:category:collection'])]
  52.     private ?string $imageFile null;
  53.     /**
  54.      * @var File
  55.      */
  56.     public $image;
  57.     #[ORM\Column(nullablefalse)]
  58.     #[Groups(['read:category:collection'])]
  59.     private ?bool $isSubCategory null;
  60.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'subCategories')]
  61.     private ?self $category null;
  62.     #[ORM\OneToMany(mappedBy'category'targetEntityself::class)]
  63.     private Collection $subCategories;
  64.     #[ORM\OneToMany(mappedBy'discipline'targetEntityEnseignant::class)]
  65.     private Collection $enseignants;
  66.     #[ORM\OneToMany(mappedBy'category'targetEntityExam::class)]
  67.     private Collection $exams;
  68.     #[ORM\OneToMany(mappedBy'matiere'targetEntityEvaluation::class, orphanRemovaltrue)]
  69.     private Collection $evaluations;
  70.     #[ORM\OneToMany(mappedBy'matiere'targetEntityMatiereCycle::class, orphanRemovaltrue)]
  71.     private Collection $matiereCycles;
  72.     #[ORM\OneToMany(mappedBy'matiere'targetEntitySubjectChat::class, orphanRemovaltrue)]
  73.     private Collection $subjectChats;
  74.     public function __construct()
  75.     {
  76.         $this->cours = new ArrayCollection();
  77.         $this->subCategories = new ArrayCollection();
  78.         $this->enseignants = new ArrayCollection();
  79.         $this->exams = new ArrayCollection();
  80.         $this->isSubCategory false;
  81.         $this->evaluations = new ArrayCollection();
  82.         $this->matiereCycles = new ArrayCollection();
  83.         $this->subjectChats = new ArrayCollection();
  84.     }
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getName(): ?string
  90.     {
  91.         return $this->name;
  92.     }
  93.     public function setName(string $name): self
  94.     {
  95.         $this->name $name;
  96.         return $this;
  97.     }
  98.     public function getSlug(): ?string
  99.     {
  100.         return $this->slug;
  101.     }
  102.     public function setSlug(string $slug): self
  103.     {
  104.         $this->slug $slug;
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, Cours>
  109.      */
  110.     public function getCours(): Collection
  111.     {
  112.         return $this->cours;
  113.     }
  114.     public function addCour(Cours $cour): self
  115.     {
  116.         if (!$this->cours->contains($cour)) {
  117.             $this->cours->add($cour);
  118.             $cour->setCategorie($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeCour(Cours $cour): self
  123.     {
  124.         if ($this->cours->removeElement($cour)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($cour->getCategorie() === $this) {
  127.                 $cour->setCategorie(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     public function getImageFile(): ?string
  133.     {
  134.         return $this->imageFile;
  135.     }
  136.     public function setImageFile(?string $imageFile): self
  137.     {
  138.         $this->imageFile $imageFile;
  139.         return $this;
  140.     }
  141.     public function isIsSubCategory(): ?bool
  142.     {
  143.         return $this->isSubCategory;
  144.     }
  145.     public function setIsSubCategory(?bool $isSubCategory): self
  146.     {
  147.         $this->isSubCategory $isSubCategory;
  148.         return $this;
  149.     }
  150.     public function getCategory(): ?self
  151.     {
  152.         return $this->category;
  153.     }
  154.     public function setCategory(?self $category): self
  155.     {
  156.         $this->category $category;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, self>
  161.      */
  162.     public function getSubCategories(): Collection
  163.     {
  164.         return $this->subCategories;
  165.     }
  166.     public function addSubCategory(self $subCategory): self
  167.     {
  168.         if (!$this->subCategories->contains($subCategory)) {
  169.             $this->subCategories->add($subCategory);
  170.             $subCategory->setCategory($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeSubCategory(self $subCategory): self
  175.     {
  176.         if ($this->subCategories->removeElement($subCategory)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($subCategory->getCategory() === $this) {
  179.                 $subCategory->setCategory(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection<int, Enseignant>
  186.      */
  187.     public function getEnseignants(): Collection
  188.     {
  189.         return $this->enseignants;
  190.     }
  191.     public function addEnseignant(Enseignant $enseignant): self
  192.     {
  193.         if (!$this->enseignants->contains($enseignant)) {
  194.             $this->enseignants->add($enseignant);
  195.             $enseignant->setDiscipline($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeEnseignant(Enseignant $enseignant): self
  200.     {
  201.         if ($this->enseignants->removeElement($enseignant)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($enseignant->getDiscipline() === $this) {
  204.                 $enseignant->setDiscipline(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection<int, Exam>
  211.      */
  212.     public function getExams(): Collection
  213.     {
  214.         return $this->exams;
  215.     }
  216.     public function addExam(Exam $exam): self
  217.     {
  218.         if (!$this->exams->contains($exam)) {
  219.             $this->exams->add($exam);
  220.             $exam->setCategory($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeExam(Exam $exam): self
  225.     {
  226.         if ($this->exams->removeElement($exam)) {
  227.             // set the owning side to null (unless already changed)
  228.             if ($exam->getCategory() === $this) {
  229.                 $exam->setCategory(null);
  230.             }
  231.         }
  232.         return $this;
  233.     }
  234.     /**
  235.      * @return Collection<int, Evaluation>
  236.      */
  237.     public function getEvaluations(): Collection
  238.     {
  239.         return $this->evaluations;
  240.     }
  241.     public function addEvaluation(Evaluation $evaluation): self
  242.     {
  243.         if (!$this->evaluations->contains($evaluation)) {
  244.             $this->evaluations->add($evaluation);
  245.             $evaluation->setMatiere($this);
  246.         }
  247.         return $this;
  248.     }
  249.     public function removeEvaluation(Evaluation $evaluation): self
  250.     {
  251.         if ($this->evaluations->removeElement($evaluation)) {
  252.             // set the owning side to null (unless already changed)
  253.             if ($evaluation->getMatiere() === $this) {
  254.                 $evaluation->setMatiere(null);
  255.             }
  256.         }
  257.         return $this;
  258.     }
  259.     /**
  260.      * @return Collection<int, MatiereCycle>
  261.      */
  262.     public function getMatiereCycles(): Collection
  263.     {
  264.         return $this->matiereCycles;
  265.     }
  266.     public function addMatiereCycle(MatiereCycle $matiereCycle): static
  267.     {
  268.         if (!$this->matiereCycles->contains($matiereCycle)) {
  269.             $this->matiereCycles->add($matiereCycle);
  270.             $matiereCycle->setMatiere($this);
  271.         }
  272.         return $this;
  273.     }
  274.     public function removeMatiereCycle(MatiereCycle $matiereCycle): static
  275.     {
  276.         if ($this->matiereCycles->removeElement($matiereCycle)) {
  277.             // set the owning side to null (unless already changed)
  278.             if ($matiereCycle->getMatiere() === $this) {
  279.                 $matiereCycle->setMatiere(null);
  280.             }
  281.         }
  282.         return $this;
  283.     }
  284.     /**
  285.      * @return Collection<int, SubjectChat>
  286.      */
  287.     public function getSubjectChats(): Collection
  288.     {
  289.         return $this->subjectChats;
  290.     }
  291.     public function addSubjectChat(SubjectChat $chat): static
  292.     {
  293.         if (!$this->subjectChats->contains($chat)) {
  294.             $this->subjectChats->add($chat);
  295.             $chat->setMatiere($this);
  296.         }
  297.         return $this;
  298.     }
  299.     public function removeSubjectChat(SubjectChat $chat): static
  300.     {
  301.         if ($this->subjectChats->removeElement($chat)) {
  302.             if ($chat->getMatiere() === $this) {
  303.                 $chat->setMatiere(null);
  304.             }
  305.         }
  306.         return $this;
  307.     }
  308. }