src/Entity/Subject.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubjectRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Traits\Timestampable;
  8. use JMS\Serializer\Annotation\Groups;
  9. #[ORM\HasLifecycleCallbacks]
  10. #[ORM\Entity(repositoryClassSubjectRepository::class)]
  11. class Subject
  12. {
  13.     use Timestampable;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     #[Groups(['getAbsence','homework','note','getBulletin''getAgenda''getExamAgenda'])]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     #[Groups(['getAbsence','homework','note','getBulletin','getDiscussion''getAgenda''getExamAgenda'])]
  21.     private ?string $name null;
  22.     #[ORM\Column]
  23.     #[Groups(['getBulletin','getSubject'])]
  24.     private ?float $coef null;
  25.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'subjects')]
  26.     #[Groups(["getSubject"])]
  27.     private ?TheClass $classe null;
  28.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'subjects')]
  29.     #[Groups(["getSubject"])]
  30.     private ?User $prof null;
  31.     #[ORM\Column]
  32.     private ?bool $active null;
  33.     #[ORM\OneToMany(mappedBy'subject'targetEntityHomeWork::class)]
  34.     private Collection $homeWorks;
  35.     #[ORM\OneToMany(mappedBy'subject'targetEntityAbsence::class)]
  36.     private Collection $absences;
  37.     #[ORM\ManyToOne(inversedBy'subjects'cascade: ["persist"])]
  38.     #[ORM\JoinColumn(nullablefalse)]
  39.     private ?SubjectGroup $subjectGroup null;
  40.     #[ORM\OneToMany(mappedBy'subject'targetEntityNote::class)]
  41.     private Collection $notes;
  42.     #[ORM\OneToMany(mappedBy'subject'targetEntityExams::class)]
  43.     private Collection $exams;
  44.     #[ORM\ManyToOne(inversedBy'subjectsEdited'cascade: ["persist"])]
  45.     private ?User $editor null;
  46.     #[ORM\ManyToOne(inversedBy'subjectsCreated'cascade: ["persist"])]
  47.     private ?User $author null;
  48.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'subjects')]
  49.     #[Groups(['getSubject'])]
  50.     private ?School $school null;
  51.     #[ORM\OneToMany(mappedBy'subject'targetEntityAgendaElement::class)]
  52.     private Collection $agendaElements;
  53.     #[ORM\OneToMany(mappedBy'subject'targetEntityExamAgendaElement::class)]
  54.     private Collection $examAgendaElements;
  55.     #[Groups(['getAbsence','homework','note','getBulletin','getDiscussion''getAgenda''getExamAgenda'])]
  56.     #[ORM\Column(length255nullabletrue)]
  57.     private ?string $competence null;
  58.     #[ORM\OneToMany(mappedBy'subject'targetEntityParentNote::class)]
  59.     private Collection $parentNotes;
  60.     #[ORM\ManyToOne(inversedBy'subjects')]
  61.     private ?SchoolYear $year null;
  62.     #[ORM\OneToOne(mappedBy'subject'cascade: ['persist''remove'])]
  63.     private ?PrimaryParentNote $primaryParentNote null;
  64.     #[ORM\OneToMany(mappedBy'subject'targetEntityPrimaryNote::class)]
  65.     private Collection $primaryNotes;
  66.     #[ORM\Column(nullabletrue)]
  67.     private ?float $point null;
  68.     #[ORM\Column(nullabletrue)]
  69.     private ?float $totalPoints null;
  70.     #[ORM\OneToMany(mappedBy'subject'targetEntitySubNote::class, orphanRemovaltrue)]
  71.     private Collection $subNotes;
  72.     #[ORM\OneToMany(mappedBy'subject'targetEntityTimeTable::class)]
  73.     private Collection $timeTables;
  74.     public function __toString():string
  75.     {
  76.         return $this->name;
  77.     }
  78.     public function __construct()
  79.     {
  80.         $this->homeWorks = new ArrayCollection();
  81.         $this->absences = new ArrayCollection();
  82.         $this->notes = new ArrayCollection();
  83.         $this->exams = new ArrayCollection();
  84.         $this->agendaElements = new ArrayCollection();
  85.         $this->examAgendaElements = new ArrayCollection();
  86.         $this->parentNotes = new ArrayCollection();
  87.         $this->primaryNotes = new ArrayCollection();
  88.         $this->subNotes = new ArrayCollection();
  89.         $this->timeTables = new ArrayCollection();
  90.     }
  91.     public function getId(): ?int
  92.     {
  93.         return $this->id;
  94.     }
  95.     public function getName(): ?string
  96.     {
  97.         return $this->name;
  98.     }
  99.     public function setName(string $name): static
  100.     {
  101.         $this->name $name;
  102.         return $this;
  103.     }
  104.     public function getCoef(): ?float
  105.     {
  106.         return $this->coef;
  107.     }
  108.     public function setCoef(float $coef): static
  109.     {
  110.         $this->coef $coef;
  111.         return $this;
  112.     }
  113.     public function getClasse(): ?TheClass
  114.     {
  115.         return $this->classe;
  116.     }
  117.     public function setClasse(?TheClass $classe): static
  118.     {
  119.         $this->classe $classe;
  120.         return $this;
  121.     }
  122.     public function getProf(): ?User
  123.     {
  124.         return $this->prof;
  125.     }
  126.     public function setProf(?User $prof): static
  127.     {
  128.         $this->prof $prof;
  129.         return $this;
  130.     }
  131.     public function isActive(): ?bool
  132.     {
  133.         return $this->active;
  134.     }
  135.     public function setActive(bool $active): static
  136.     {
  137.         $this->active $active;
  138.         return $this;
  139.     }
  140.     /**
  141.      * @return Collection<int, HomeWork>
  142.      */
  143.     public function getHomeWorks(): Collection
  144.     {
  145.         return $this->homeWorks;
  146.     }
  147.     public function addHomeWork(HomeWork $homeWork): static
  148.     {
  149.         if (!$this->homeWorks->contains($homeWork)) {
  150.             $this->homeWorks->add($homeWork);
  151.             $homeWork->setSubject($this);
  152.         }
  153.         return $this;
  154.     }
  155.     public function removeHomeWork(HomeWork $homeWork): static
  156.     {
  157.         if ($this->homeWorks->removeElement($homeWork)) {
  158.             // set the owning side to null (unless already changed)
  159.             if ($homeWork->getSubject() === $this) {
  160.                 $homeWork->setSubject(null);
  161.             }
  162.         }
  163.         return $this;
  164.     }
  165.     /**
  166.      * @return Collection<int, Absence>
  167.      */
  168.     public function getAbsences(): Collection
  169.     {
  170.         return $this->absences;
  171.     }
  172.     public function addAbsence(Absence $absence): static
  173.     {
  174.         if (!$this->absences->contains($absence)) {
  175.             $this->absences->add($absence);
  176.             $absence->setSubject($this);
  177.         }
  178.         return $this;
  179.     }
  180.     public function removeAbsence(Absence $absence): static
  181.     {
  182.         if ($this->absences->removeElement($absence)) {
  183.             // set the owning side to null (unless already changed)
  184.             if ($absence->getSubject() === $this) {
  185.                 $absence->setSubject(null);
  186.             }
  187.         }
  188.         return $this;
  189.     }
  190.     public function getSubjectGroup(): ?SubjectGroup
  191.     {
  192.         return $this->subjectGroup;
  193.     }
  194.     public function setSubjectGroup(?SubjectGroup $subjectGroup): static
  195.     {
  196.         $this->subjectGroup $subjectGroup;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @return Collection<int, Note>
  201.      */
  202.     public function getNotes(): Collection
  203.     {
  204.         return $this->notes;
  205.     }
  206.     public function addNote(Note $note): static
  207.     {
  208.         if (!$this->notes->contains($note)) {
  209.             $this->notes->add($note);
  210.             $note->setSubject($this);
  211.         }
  212.         return $this;
  213.     }
  214.     public function removeNote(Note $note): static
  215.     {
  216.         if ($this->notes->removeElement($note)) {
  217.             // set the owning side to null (unless already changed)
  218.             if ($note->getSubject() === $this) {
  219.                 $note->setSubject(null);
  220.             }
  221.         }
  222.         return $this;
  223.     }
  224.     /**
  225.      * @return Collection<int, Exams>
  226.      */
  227.     public function getExams(): Collection
  228.     {
  229.         return $this->exams;
  230.     }
  231.     public function addExam(Exams $exam): static
  232.     {
  233.         if (!$this->exams->contains($exam)) {
  234.             $this->exams->add($exam);
  235.             $exam->setSubject($this);
  236.         }
  237.         return $this;
  238.     }
  239.     public function removeExam(Exams $exam): static
  240.     {
  241.         if ($this->exams->removeElement($exam)) {
  242.             // set the owning side to null (unless already changed)
  243.             if ($exam->getSubject() === $this) {
  244.                 $exam->setSubject(null);
  245.             }
  246.         }
  247.         return $this;
  248.     }
  249.     public function getEditor(): ?User
  250.     {
  251.         return $this->editor;
  252.     }
  253.     public function setEditor(?User $editor): static
  254.     {
  255.         $this->editor $editor;
  256.         return $this;
  257.     }
  258.     public function getAuthor(): ?User
  259.     {
  260.         return $this->author;
  261.     }
  262.     public function setAuthor(?User $author): static
  263.     {
  264.         $this->author $author;
  265.         return $this;
  266.     }
  267.     public function getSchool(): ?School
  268.     {
  269.         return $this->school;
  270.     }
  271.     public function setSchool(?School $school): static
  272.     {
  273.         $this->school $school;
  274.         return $this;
  275.     }
  276.     /**
  277.      * @return Collection<int, AgendaElement>
  278.      */
  279.     public function getAgendaElements(): Collection
  280.     {
  281.         return $this->agendaElements;
  282.     }
  283.     public function addAgendaElement(AgendaElement $agendaElement): static
  284.     {
  285.         if (!$this->agendaElements->contains($agendaElement)) {
  286.             $this->agendaElements->add($agendaElement);
  287.             $agendaElement->setSubject($this);
  288.         }
  289.         return $this;
  290.     }
  291.     public function removeAgendaElement(AgendaElement $agendaElement): static
  292.     {
  293.         if ($this->agendaElements->removeElement($agendaElement)) {
  294.             // set the owning side to null (unless already changed)
  295.             if ($agendaElement->getSubject() === $this) {
  296.                 $agendaElement->setSubject(null);
  297.             }
  298.         }
  299.         return $this;
  300.     }
  301.     /**
  302.      * @return Collection<int, ExamAgendaElement>
  303.      */
  304.     public function getExamAgendaElements(): Collection
  305.     {
  306.         return $this->examAgendaElements;
  307.     }
  308.     public function addExamAgendaElement(ExamAgendaElement $examAgendaElement): static
  309.     {
  310.         if (!$this->examAgendaElements->contains($examAgendaElement)) {
  311.             $this->examAgendaElements->add($examAgendaElement);
  312.             $examAgendaElement->setSubject($this);
  313.         }
  314.         return $this;
  315.     }
  316.     public function removeExamAgendaElement(ExamAgendaElement $examAgendaElement): static
  317.     {
  318.         if ($this->examAgendaElements->removeElement($examAgendaElement)) {
  319.             // set the owning side to null (unless already changed)
  320.             if ($examAgendaElement->getSubject() === $this) {
  321.                 $examAgendaElement->setSubject(null);
  322.             }
  323.         }
  324.         return $this;
  325.     }
  326.     public function getCompetence(): ?string
  327.     {
  328.         return $this->competence;
  329.     }
  330.     public function setCompetence(?string $competence): static
  331.     {
  332.         $this->competence $competence;
  333.         return $this;
  334.     }
  335.     /**
  336.      * @return Collection<int, ParentNote>
  337.      */
  338.     public function getParentNotes(): Collection
  339.     {
  340.         return $this->parentNotes;
  341.     }
  342.     public function addParentNote(ParentNote $parentNote): static
  343.     {
  344.         if (!$this->parentNotes->contains($parentNote)) {
  345.             $this->parentNotes->add($parentNote);
  346.             $parentNote->setSubject($this);
  347.         }
  348.         return $this;
  349.     }
  350.     /* 
  351.         @return Collection<int, SubNote>
  352.      */
  353.     public function getSubNotes(): Collection
  354.     {
  355.         return $this->subNotes;
  356.     }
  357.     public function addSubNote(SubNote $subNote): static
  358.     {
  359.         if (!$this->subNotes->contains($subNote)) {
  360.             $this->subNotes->add($subNote);
  361.             $subNote->setSubject($this);
  362.         }
  363.         return $this;
  364.     }
  365.     public function removeParentNote(ParentNote $parentNote): static
  366.     {
  367.         if ($this->parentNotes->removeElement($parentNote)) {
  368.             // set the owning side to null (unless already changed)
  369.             if ($parentNote->getSubject() === $this) {
  370.                 $parentNote->setSubject(null);
  371.             }
  372.         }
  373.         return $this;
  374.     }
  375.     public function removeSubNote(SubNote $subNote): static
  376.     {
  377.         if ($this->subNotes->removeElement($subNote)) {
  378.             // set the owning side to null (unless already changed)
  379.             if ($subNote->getSubject() === $this) {
  380.                 $subNote->setSubject(null);
  381.             }
  382.         }
  383.         return $this;
  384.     }
  385.     public function getYear(): ?SchoolYear
  386.     {
  387.         return $this->year;
  388.     }
  389.     public function setYear(?SchoolYear $year): static
  390.     {
  391.         $this->year $year;
  392.         return $this;
  393.     }
  394.     public function getPrimaryParentNote(): ?PrimaryParentNote
  395.     {
  396.         return $this->primaryParentNote;
  397.     }
  398.     public function setPrimaryParentNote(PrimaryParentNote $primaryParentNote): static
  399.     {
  400.         // set the owning side of the relation if necessary
  401.         if ($primaryParentNote->getSubject() !== $this) {
  402.             $primaryParentNote->setSubject($this);
  403.         }
  404.         $this->primaryParentNote $primaryParentNote;
  405.         return $this;
  406.     }
  407.     /**
  408.      * @return Collection<int, PrimaryNote>
  409.      */
  410.     public function getPrimaryNotes(): Collection
  411.     {
  412.         return $this->primaryNotes;
  413.     }
  414.     public function addPrimaryNote(PrimaryNote $primaryNote): static
  415.     {
  416.         if (!$this->primaryNotes->contains($primaryNote)) {
  417.             $this->primaryNotes->add($primaryNote);
  418.             $primaryNote->setSubject($this);
  419.         }
  420.         return $this;
  421.     }
  422.     public function removePrimaryNote(PrimaryNote $primaryNote): static
  423.     {
  424.         if ($this->primaryNotes->removeElement($primaryNote)) {
  425.             // set the owning side to null (unless already changed)
  426.             if ($primaryNote->getSubject() === $this) {
  427.                 $primaryNote->setSubject(null);
  428.             }
  429.         }
  430.         return $this;
  431.     }
  432.     public function getPoint(): ?float
  433.     {
  434.         return $this->point;
  435.     }
  436.     public function setPoint(?float $point): static
  437.     {
  438.         $this->point $point;
  439.         return $this;
  440.     }
  441.     public function getTotalPoints(): ?float
  442.     {
  443.         return $this->totalPoints;
  444.     }
  445.     public function setTotalPoints(?float $totalPoints): static
  446.     {
  447.         $this->totalPoints $totalPoints;
  448.         return $this;
  449.     }
  450.     /**
  451.      * @return Collection<int, TimeTable>
  452.      */
  453.     public function getTimeTables(): Collection
  454.     {
  455.         return $this->timeTables;
  456.     }
  457.     public function addTimeTable(TimeTable $timeTable): static
  458.     {
  459.         if (!$this->timeTables->contains($timeTable)) {
  460.             $this->timeTables->add($timeTable);
  461.             $timeTable->setSubject($this);
  462.         }
  463.         return $this;
  464.     }
  465.     public function removeTimeTable(TimeTable $timeTable): static
  466.     {
  467.         if ($this->timeTables->removeElement($timeTable)) {
  468.             // set the owning side to null (unless already changed)
  469.             if ($timeTable->getSubject() === $this) {
  470.                 $timeTable->setSubject(null);
  471.             }
  472.         }
  473.         return $this;
  474.     }
  475. }