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'targetEntityCompetence::class, cascade: ["persist""remove"], orphanRemovaltrue)]
  73.     private Collection $competences;
  74.     #[ORM\OneToMany(mappedBy'subject'targetEntityWeekSubjectGoal::class)]
  75.     private Collection $weekSubjectGoals;
  76.     #[ORM\OneToMany(mappedBy'subject'targetEntityProfSchoolPlanner::class)]
  77.     private Collection $profSchoolPlanners;
  78.     #[ORM\Column(nullabletrue)]
  79.     private ?float $longitude null;
  80.     #[ORM\Column(nullabletrue)]
  81.     private ?float $latitude null;
  82.     #[ORM\OneToMany(mappedBy'subject'targetEntityProfTime::class)]
  83.     private Collection $profTimes;
  84.     public function __toString():string
  85.     {
  86.         return $this->name;
  87.     }
  88.     public function __construct()
  89.     {
  90.         $this->homeWorks = new ArrayCollection();
  91.         $this->absences = new ArrayCollection();
  92.         $this->notes = new ArrayCollection();
  93.         $this->exams = new ArrayCollection();
  94.         $this->agendaElements = new ArrayCollection();
  95.         $this->examAgendaElements = new ArrayCollection();
  96.         $this->parentNotes = new ArrayCollection();
  97.         $this->primaryNotes = new ArrayCollection();
  98.         $this->subNotes = new ArrayCollection();
  99.         $this->competences = new ArrayCollection();
  100.         $this->weekSubjectGoals = new ArrayCollection();
  101.         $this->profSchoolPlanners = new ArrayCollection();
  102.         $this->profTimes = new ArrayCollection();
  103.     }
  104.     public function getId(): ?int
  105.     {
  106.         return $this->id;
  107.     }
  108.     public function getName(): ?string
  109.     {
  110.         return $this->name;
  111.     }
  112.     public function setName(string $name): static
  113.     {
  114.         $this->name $name;
  115.         return $this;
  116.     }
  117.     public function getCoef(): ?float
  118.     {
  119.         return $this->coef;
  120.     }
  121.     public function setCoef(float $coef): static
  122.     {
  123.         $this->coef $coef;
  124.         return $this;
  125.     }
  126.     public function getClasse(): ?TheClass
  127.     {
  128.         return $this->classe;
  129.     }
  130.     public function setClasse(?TheClass $classe): static
  131.     {
  132.         $this->classe $classe;
  133.         return $this;
  134.     }
  135.     public function getProf(): ?User
  136.     {
  137.         return $this->prof;
  138.     }
  139.     public function setProf(?User $prof): static
  140.     {
  141.         $this->prof $prof;
  142.         return $this;
  143.     }
  144.     public function isActive(): ?bool
  145.     {
  146.         return $this->active;
  147.     }
  148.     public function setActive(bool $active): static
  149.     {
  150.         $this->active $active;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return Collection<int, HomeWork>
  155.      */
  156.     public function getHomeWorks(): Collection
  157.     {
  158.         return $this->homeWorks;
  159.     }
  160.     public function addHomeWork(HomeWork $homeWork): static
  161.     {
  162.         if (!$this->homeWorks->contains($homeWork)) {
  163.             $this->homeWorks->add($homeWork);
  164.             $homeWork->setSubject($this);
  165.         }
  166.         return $this;
  167.     }
  168.     public function removeHomeWork(HomeWork $homeWork): static
  169.     {
  170.         if ($this->homeWorks->removeElement($homeWork)) {
  171.             // set the owning side to null (unless already changed)
  172.             if ($homeWork->getSubject() === $this) {
  173.                 $homeWork->setSubject(null);
  174.             }
  175.         }
  176.         return $this;
  177.     }
  178.     /**
  179.      * @return Collection<int, Absence>
  180.      */
  181.     public function getAbsences(): Collection
  182.     {
  183.         return $this->absences;
  184.     }
  185.     public function addAbsence(Absence $absence): static
  186.     {
  187.         if (!$this->absences->contains($absence)) {
  188.             $this->absences->add($absence);
  189.             $absence->setSubject($this);
  190.         }
  191.         return $this;
  192.     }
  193.     public function removeAbsence(Absence $absence): static
  194.     {
  195.         if ($this->absences->removeElement($absence)) {
  196.             // set the owning side to null (unless already changed)
  197.             if ($absence->getSubject() === $this) {
  198.                 $absence->setSubject(null);
  199.             }
  200.         }
  201.         return $this;
  202.     }
  203.     public function getSubjectGroup(): ?SubjectGroup
  204.     {
  205.         return $this->subjectGroup;
  206.     }
  207.     public function setSubjectGroup(?SubjectGroup $subjectGroup): static
  208.     {
  209.         $this->subjectGroup $subjectGroup;
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection<int, Note>
  214.      */
  215.     public function getNotes(): Collection
  216.     {
  217.         return $this->notes;
  218.     }
  219.     public function addNote(Note $note): static
  220.     {
  221.         if (!$this->notes->contains($note)) {
  222.             $this->notes->add($note);
  223.             $note->setSubject($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeNote(Note $note): static
  228.     {
  229.         if ($this->notes->removeElement($note)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($note->getSubject() === $this) {
  232.                 $note->setSubject(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection<int, Exams>
  239.      */
  240.     public function getExams(): Collection
  241.     {
  242.         return $this->exams;
  243.     }
  244.     public function addExam(Exams $exam): static
  245.     {
  246.         if (!$this->exams->contains($exam)) {
  247.             $this->exams->add($exam);
  248.             $exam->setSubject($this);
  249.         }
  250.         return $this;
  251.     }
  252.     public function removeExam(Exams $exam): static
  253.     {
  254.         if ($this->exams->removeElement($exam)) {
  255.             // set the owning side to null (unless already changed)
  256.             if ($exam->getSubject() === $this) {
  257.                 $exam->setSubject(null);
  258.             }
  259.         }
  260.         return $this;
  261.     }
  262.     public function getEditor(): ?User
  263.     {
  264.         return $this->editor;
  265.     }
  266.     public function setEditor(?User $editor): static
  267.     {
  268.         $this->editor $editor;
  269.         return $this;
  270.     }
  271.     public function getAuthor(): ?User
  272.     {
  273.         return $this->author;
  274.     }
  275.     public function setAuthor(?User $author): static
  276.     {
  277.         $this->author $author;
  278.         return $this;
  279.     }
  280.     public function getSchool(): ?School
  281.     {
  282.         return $this->school;
  283.     }
  284.     public function setSchool(?School $school): static
  285.     {
  286.         $this->school $school;
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection<int, AgendaElement>
  291.      */
  292.     public function getAgendaElements(): Collection
  293.     {
  294.         return $this->agendaElements;
  295.     }
  296.     public function addAgendaElement(AgendaElement $agendaElement): static
  297.     {
  298.         if (!$this->agendaElements->contains($agendaElement)) {
  299.             $this->agendaElements->add($agendaElement);
  300.             $agendaElement->setSubject($this);
  301.         }
  302.         return $this;
  303.     }
  304.     public function removeAgendaElement(AgendaElement $agendaElement): static
  305.     {
  306.         if ($this->agendaElements->removeElement($agendaElement)) {
  307.             // set the owning side to null (unless already changed)
  308.             if ($agendaElement->getSubject() === $this) {
  309.                 $agendaElement->setSubject(null);
  310.             }
  311.         }
  312.         return $this;
  313.     }
  314.     /**
  315.      * @return Collection<int, ExamAgendaElement>
  316.      */
  317.     public function getExamAgendaElements(): Collection
  318.     {
  319.         return $this->examAgendaElements;
  320.     }
  321.     public function addExamAgendaElement(ExamAgendaElement $examAgendaElement): static
  322.     {
  323.         if (!$this->examAgendaElements->contains($examAgendaElement)) {
  324.             $this->examAgendaElements->add($examAgendaElement);
  325.             $examAgendaElement->setSubject($this);
  326.         }
  327.         return $this;
  328.     }
  329.     public function removeExamAgendaElement(ExamAgendaElement $examAgendaElement): static
  330.     {
  331.         if ($this->examAgendaElements->removeElement($examAgendaElement)) {
  332.             // set the owning side to null (unless already changed)
  333.             if ($examAgendaElement->getSubject() === $this) {
  334.                 $examAgendaElement->setSubject(null);
  335.             }
  336.         }
  337.         return $this;
  338.     }
  339.     public function getCompetence(): ?string
  340.     {
  341.         return $this->competence;
  342.     }
  343.     public function setCompetence(?string $competence): static
  344.     {
  345.         $this->competence $competence;
  346.         return $this;
  347.     }
  348.     /**
  349.      * @return Collection<int, ParentNote>
  350.      */
  351.     public function getParentNotes(): Collection
  352.     {
  353.         return $this->parentNotes;
  354.     }
  355.     public function addParentNote(ParentNote $parentNote): static
  356.     {
  357.         if (!$this->parentNotes->contains($parentNote)) {
  358.             $this->parentNotes->add($parentNote);
  359.             $parentNote->setSubject($this);
  360.         }
  361.         return $this;
  362.     }
  363.     /* 
  364.         @return Collection<int, SubNote>
  365.      */
  366.     public function getSubNotes(): Collection
  367.     {
  368.         return $this->subNotes;
  369.     }
  370.     public function addSubNote(SubNote $subNote): static
  371.     {
  372.         if (!$this->subNotes->contains($subNote)) {
  373.             $this->subNotes->add($subNote);
  374.             $subNote->setSubject($this);
  375.         }
  376.         return $this;
  377.     }
  378.     public function removeParentNote(ParentNote $parentNote): static
  379.     {
  380.         if ($this->parentNotes->removeElement($parentNote)) {
  381.             // set the owning side to null (unless already changed)
  382.             if ($parentNote->getSubject() === $this) {
  383.                 $parentNote->setSubject(null);
  384.             }
  385.         }
  386.         return $this;
  387.     }
  388.     public function removeSubNote(SubNote $subNote): static
  389.     {
  390.         if ($this->subNotes->removeElement($subNote)) {
  391.             // set the owning side to null (unless already changed)
  392.             if ($subNote->getSubject() === $this) {
  393.                 $subNote->setSubject(null);
  394.             }
  395.         }
  396.         return $this;
  397.     }
  398.     public function getYear(): ?SchoolYear
  399.     {
  400.         return $this->year;
  401.     }
  402.     public function setYear(?SchoolYear $year): static
  403.     {
  404.         $this->year $year;
  405.         return $this;
  406.     }
  407.     public function getPrimaryParentNote(): ?PrimaryParentNote
  408.     {
  409.         return $this->primaryParentNote;
  410.     }
  411.     public function setPrimaryParentNote(PrimaryParentNote $primaryParentNote): static
  412.     {
  413.         // set the owning side of the relation if necessary
  414.         if ($primaryParentNote->getSubject() !== $this) {
  415.             $primaryParentNote->setSubject($this);
  416.         }
  417.         $this->primaryParentNote $primaryParentNote;
  418.         return $this;
  419.     }
  420.     /**
  421.      * @return Collection<int, PrimaryNote>
  422.      */
  423.     public function getPrimaryNotes(): Collection
  424.     {
  425.         return $this->primaryNotes;
  426.     }
  427.     public function addPrimaryNote(PrimaryNote $primaryNote): static
  428.     {
  429.         if (!$this->primaryNotes->contains($primaryNote)) {
  430.             $this->primaryNotes->add($primaryNote);
  431.             $primaryNote->setSubject($this);
  432.         }
  433.         return $this;
  434.     }
  435.     public function removePrimaryNote(PrimaryNote $primaryNote): static
  436.     {
  437.         if ($this->primaryNotes->removeElement($primaryNote)) {
  438.             // set the owning side to null (unless already changed)
  439.             if ($primaryNote->getSubject() === $this) {
  440.                 $primaryNote->setSubject(null);
  441.             }
  442.         }
  443.         return $this;
  444.     }
  445.     public function getPoint(): ?float
  446.     {
  447.         return $this->point;
  448.     }
  449.     public function setPoint(?float $point): static
  450.     {
  451.         $this->point $point;
  452.         return $this;
  453.     }
  454.     public function getTotalPoints(): ?float
  455.     {
  456.         return $this->totalPoints;
  457.     }
  458.     public function setTotalPoints(?float $totalPoints): static
  459.     {
  460.         $this->totalPoints $totalPoints;
  461.         return $this;
  462.     }
  463.     /**
  464.      * @return Collection<int, Competence>
  465.      */
  466.     public function getCompetences(): Collection
  467.     {
  468.         return $this->competences;
  469.     }
  470.     public function addCompetence(Competence $competence): static
  471.     {
  472.         if (!$this->competences->contains($competence)) {
  473.             $this->competences->add($competence);
  474.             $competence->setSubject($this);
  475.         }
  476.         return $this;
  477.     }
  478.     public function removeCompetence(Competence $competence): static
  479.     {
  480.         if ($this->competences->removeElement($competence)) {
  481.             // set the owning side to null (unless already changed)
  482.             if ($competence->getSubject() === $this) {
  483.                 $competence->setSubject(null);
  484.             }
  485.         }
  486.         return $this;
  487.     }
  488.     /**
  489.      * @return Collection<int, WeekSubjectGoal>
  490.      */
  491.     public function getWeekSubjectGoals(): Collection
  492.     {
  493.         return $this->weekSubjectGoals;
  494.     }
  495.     public function addWeekSubjectGoal(WeekSubjectGoal $weekSubjectGoal): static
  496.     {
  497.         if (!$this->weekSubjectGoals->contains($weekSubjectGoal)) {
  498.             $this->weekSubjectGoals->add($weekSubjectGoal);
  499.             $weekSubjectGoal->setSubject($this);
  500.         }
  501.         return $this;
  502.     }
  503.     public function removeWeekSubjectGoal(WeekSubjectGoal $weekSubjectGoal): static
  504.     {
  505.         if ($this->weekSubjectGoals->removeElement($weekSubjectGoal)) {
  506.             // set the owning side to null (unless already changed)
  507.             if ($weekSubjectGoal->getSubject() === $this) {
  508.                 $weekSubjectGoal->setSubject(null);
  509.             }
  510.         }
  511.         return $this;
  512.     }
  513.     /**
  514.      * @return Collection<int, ProfSchoolPlanner>
  515.      */
  516.     public function getProfSchoolPlanners(): Collection
  517.     {
  518.         return $this->profSchoolPlanners;
  519.     }
  520.     public function addProfSchoolPlanner(ProfSchoolPlanner $profSchoolPlanner): static
  521.     {
  522.         if (!$this->profSchoolPlanners->contains($profSchoolPlanner)) {
  523.             $this->profSchoolPlanners->add($profSchoolPlanner);
  524.             $profSchoolPlanner->setSubject($this);
  525.         }
  526.         return $this;
  527.     }
  528.     public function removeProfSchoolPlanner(ProfSchoolPlanner $profSchoolPlanner): static
  529.     {
  530.         if ($this->profSchoolPlanners->removeElement($profSchoolPlanner)) {
  531.             // set the owning side to null (unless already changed)
  532.             if ($profSchoolPlanner->getSubject() === $this) {
  533.                 $profSchoolPlanner->setSubject(null);
  534.             }
  535.         }
  536.         return $this;
  537.     }
  538.     public function getLongitude(): ?float
  539.     {
  540.         return $this->longitude;
  541.     }
  542.     public function setLongitude(?float $longitude): static
  543.     {
  544.         $this->longitude $longitude;
  545.         return $this;
  546.     }
  547.     public function getLatitude(): ?float
  548.     {
  549.         return $this->latitude;
  550.     }
  551.     public function setLatitude(?float $latitude): static
  552.     {
  553.         $this->latitude $latitude;
  554.         return $this;
  555.     }
  556.     /**
  557.      * @return Collection<int, ProfTime>
  558.      */
  559.     public function getProfTimes(): Collection
  560.     {
  561.         return $this->profTimes;
  562.     }
  563.     public function addProfTime(ProfTime $profTime): static
  564.     {
  565.         if (!$this->profTimes->contains($profTime)) {
  566.             $this->profTimes->add($profTime);
  567.             $profTime->setSubject($this);
  568.         }
  569.         return $this;
  570.     }
  571.     public function removeProfTime(ProfTime $profTime): static
  572.     {
  573.         if ($this->profTimes->removeElement($profTime)) {
  574.             // set the owning side to null (unless already changed)
  575.             if ($profTime->getSubject() === $this) {
  576.                 $profTime->setSubject(null);
  577.             }
  578.         }
  579.         return $this;
  580.     }
  581. }