<?php
namespace App\Entity;
use App\Repository\SubjectRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Traits\Timestampable;
use JMS\Serializer\Annotation\Groups;
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: SubjectRepository::class)]
class Subject
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['getAbsence','homework','note','getBulletin', 'getAgenda', 'getExamAgenda'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['getAbsence','homework','note','getBulletin','getDiscussion', 'getAgenda', 'getExamAgenda'])]
private ?string $name = null;
#[ORM\Column]
#[Groups(['getBulletin','getSubject'])]
private ?float $coef = null;
#[ORM\ManyToOne(cascade: ["persist"], inversedBy: 'subjects')]
#[Groups(["getSubject"])]
private ?TheClass $classe = null;
#[ORM\ManyToOne(cascade: ["persist"], inversedBy: 'subjects')]
#[Groups(["getSubject"])]
private ?User $prof = null;
#[ORM\Column]
private ?bool $active = null;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: HomeWork::class)]
private Collection $homeWorks;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: Absence::class)]
private Collection $absences;
#[ORM\ManyToOne(inversedBy: 'subjects', cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
private ?SubjectGroup $subjectGroup = null;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: Note::class)]
private Collection $notes;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: Exams::class)]
private Collection $exams;
#[ORM\ManyToOne(inversedBy: 'subjectsEdited', cascade: ["persist"])]
private ?User $editor = null;
#[ORM\ManyToOne(inversedBy: 'subjectsCreated', cascade: ["persist"])]
private ?User $author = null;
#[ORM\ManyToOne(cascade: ["persist"], inversedBy: 'subjects')]
#[Groups(['getSubject'])]
private ?School $school = null;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: AgendaElement::class)]
private Collection $agendaElements;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: ExamAgendaElement::class)]
private Collection $examAgendaElements;
#[Groups(['getAbsence','homework','note','getBulletin','getDiscussion', 'getAgenda', 'getExamAgenda'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $competence = null;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: ParentNote::class)]
private Collection $parentNotes;
#[ORM\ManyToOne(inversedBy: 'subjects')]
private ?SchoolYear $year = null;
#[ORM\OneToOne(mappedBy: 'subject', cascade: ['persist', 'remove'])]
private ?PrimaryParentNote $primaryParentNote = null;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: PrimaryNote::class)]
private Collection $primaryNotes;
#[ORM\Column(nullable: true)]
private ?float $point = null;
#[ORM\Column(nullable: true)]
private ?float $totalPoints = null;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: SubNote::class, orphanRemoval: true)]
private Collection $subNotes;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: Competence::class, cascade: ["persist", "remove"], orphanRemoval: true)]
private Collection $competences;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: WeekSubjectGoal::class)]
private Collection $weekSubjectGoals;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: ProfSchoolPlanner::class)]
private Collection $profSchoolPlanners;
#[ORM\Column(nullable: true)]
private ?float $longitude = null;
#[ORM\Column(nullable: true)]
private ?float $latitude = null;
#[ORM\OneToMany(mappedBy: 'subject', targetEntity: ProfTime::class)]
private Collection $profTimes;
public function __toString():string
{
return $this->name;
}
public function __construct()
{
$this->homeWorks = new ArrayCollection();
$this->absences = new ArrayCollection();
$this->notes = new ArrayCollection();
$this->exams = new ArrayCollection();
$this->agendaElements = new ArrayCollection();
$this->examAgendaElements = new ArrayCollection();
$this->parentNotes = new ArrayCollection();
$this->primaryNotes = new ArrayCollection();
$this->subNotes = new ArrayCollection();
$this->competences = new ArrayCollection();
$this->weekSubjectGoals = new ArrayCollection();
$this->profSchoolPlanners = new ArrayCollection();
$this->profTimes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getCoef(): ?float
{
return $this->coef;
}
public function setCoef(float $coef): static
{
$this->coef = $coef;
return $this;
}
public function getClasse(): ?TheClass
{
return $this->classe;
}
public function setClasse(?TheClass $classe): static
{
$this->classe = $classe;
return $this;
}
public function getProf(): ?User
{
return $this->prof;
}
public function setProf(?User $prof): static
{
$this->prof = $prof;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): static
{
$this->active = $active;
return $this;
}
/**
* @return Collection<int, HomeWork>
*/
public function getHomeWorks(): Collection
{
return $this->homeWorks;
}
public function addHomeWork(HomeWork $homeWork): static
{
if (!$this->homeWorks->contains($homeWork)) {
$this->homeWorks->add($homeWork);
$homeWork->setSubject($this);
}
return $this;
}
public function removeHomeWork(HomeWork $homeWork): static
{
if ($this->homeWorks->removeElement($homeWork)) {
// set the owning side to null (unless already changed)
if ($homeWork->getSubject() === $this) {
$homeWork->setSubject(null);
}
}
return $this;
}
/**
* @return Collection<int, Absence>
*/
public function getAbsences(): Collection
{
return $this->absences;
}
public function addAbsence(Absence $absence): static
{
if (!$this->absences->contains($absence)) {
$this->absences->add($absence);
$absence->setSubject($this);
}
return $this;
}
public function removeAbsence(Absence $absence): static
{
if ($this->absences->removeElement($absence)) {
// set the owning side to null (unless already changed)
if ($absence->getSubject() === $this) {
$absence->setSubject(null);
}
}
return $this;
}
public function getSubjectGroup(): ?SubjectGroup
{
return $this->subjectGroup;
}
public function setSubjectGroup(?SubjectGroup $subjectGroup): static
{
$this->subjectGroup = $subjectGroup;
return $this;
}
/**
* @return Collection<int, Note>
*/
public function getNotes(): Collection
{
return $this->notes;
}
public function addNote(Note $note): static
{
if (!$this->notes->contains($note)) {
$this->notes->add($note);
$note->setSubject($this);
}
return $this;
}
public function removeNote(Note $note): static
{
if ($this->notes->removeElement($note)) {
// set the owning side to null (unless already changed)
if ($note->getSubject() === $this) {
$note->setSubject(null);
}
}
return $this;
}
/**
* @return Collection<int, Exams>
*/
public function getExams(): Collection
{
return $this->exams;
}
public function addExam(Exams $exam): static
{
if (!$this->exams->contains($exam)) {
$this->exams->add($exam);
$exam->setSubject($this);
}
return $this;
}
public function removeExam(Exams $exam): static
{
if ($this->exams->removeElement($exam)) {
// set the owning side to null (unless already changed)
if ($exam->getSubject() === $this) {
$exam->setSubject(null);
}
}
return $this;
}
public function getEditor(): ?User
{
return $this->editor;
}
public function setEditor(?User $editor): static
{
$this->editor = $editor;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): static
{
$this->author = $author;
return $this;
}
public function getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
return $this;
}
/**
* @return Collection<int, AgendaElement>
*/
public function getAgendaElements(): Collection
{
return $this->agendaElements;
}
public function addAgendaElement(AgendaElement $agendaElement): static
{
if (!$this->agendaElements->contains($agendaElement)) {
$this->agendaElements->add($agendaElement);
$agendaElement->setSubject($this);
}
return $this;
}
public function removeAgendaElement(AgendaElement $agendaElement): static
{
if ($this->agendaElements->removeElement($agendaElement)) {
// set the owning side to null (unless already changed)
if ($agendaElement->getSubject() === $this) {
$agendaElement->setSubject(null);
}
}
return $this;
}
/**
* @return Collection<int, ExamAgendaElement>
*/
public function getExamAgendaElements(): Collection
{
return $this->examAgendaElements;
}
public function addExamAgendaElement(ExamAgendaElement $examAgendaElement): static
{
if (!$this->examAgendaElements->contains($examAgendaElement)) {
$this->examAgendaElements->add($examAgendaElement);
$examAgendaElement->setSubject($this);
}
return $this;
}
public function removeExamAgendaElement(ExamAgendaElement $examAgendaElement): static
{
if ($this->examAgendaElements->removeElement($examAgendaElement)) {
// set the owning side to null (unless already changed)
if ($examAgendaElement->getSubject() === $this) {
$examAgendaElement->setSubject(null);
}
}
return $this;
}
public function getCompetence(): ?string
{
return $this->competence;
}
public function setCompetence(?string $competence): static
{
$this->competence = $competence;
return $this;
}
/**
* @return Collection<int, ParentNote>
*/
public function getParentNotes(): Collection
{
return $this->parentNotes;
}
public function addParentNote(ParentNote $parentNote): static
{
if (!$this->parentNotes->contains($parentNote)) {
$this->parentNotes->add($parentNote);
$parentNote->setSubject($this);
}
return $this;
}
/*
@return Collection<int, SubNote>
*/
public function getSubNotes(): Collection
{
return $this->subNotes;
}
public function addSubNote(SubNote $subNote): static
{
if (!$this->subNotes->contains($subNote)) {
$this->subNotes->add($subNote);
$subNote->setSubject($this);
}
return $this;
}
public function removeParentNote(ParentNote $parentNote): static
{
if ($this->parentNotes->removeElement($parentNote)) {
// set the owning side to null (unless already changed)
if ($parentNote->getSubject() === $this) {
$parentNote->setSubject(null);
}
}
return $this;
}
public function removeSubNote(SubNote $subNote): static
{
if ($this->subNotes->removeElement($subNote)) {
// set the owning side to null (unless already changed)
if ($subNote->getSubject() === $this) {
$subNote->setSubject(null);
}
}
return $this;
}
public function getYear(): ?SchoolYear
{
return $this->year;
}
public function setYear(?SchoolYear $year): static
{
$this->year = $year;
return $this;
}
public function getPrimaryParentNote(): ?PrimaryParentNote
{
return $this->primaryParentNote;
}
public function setPrimaryParentNote(PrimaryParentNote $primaryParentNote): static
{
// set the owning side of the relation if necessary
if ($primaryParentNote->getSubject() !== $this) {
$primaryParentNote->setSubject($this);
}
$this->primaryParentNote = $primaryParentNote;
return $this;
}
/**
* @return Collection<int, PrimaryNote>
*/
public function getPrimaryNotes(): Collection
{
return $this->primaryNotes;
}
public function addPrimaryNote(PrimaryNote $primaryNote): static
{
if (!$this->primaryNotes->contains($primaryNote)) {
$this->primaryNotes->add($primaryNote);
$primaryNote->setSubject($this);
}
return $this;
}
public function removePrimaryNote(PrimaryNote $primaryNote): static
{
if ($this->primaryNotes->removeElement($primaryNote)) {
// set the owning side to null (unless already changed)
if ($primaryNote->getSubject() === $this) {
$primaryNote->setSubject(null);
}
}
return $this;
}
public function getPoint(): ?float
{
return $this->point;
}
public function setPoint(?float $point): static
{
$this->point = $point;
return $this;
}
public function getTotalPoints(): ?float
{
return $this->totalPoints;
}
public function setTotalPoints(?float $totalPoints): static
{
$this->totalPoints = $totalPoints;
return $this;
}
/**
* @return Collection<int, Competence>
*/
public function getCompetences(): Collection
{
return $this->competences;
}
public function addCompetence(Competence $competence): static
{
if (!$this->competences->contains($competence)) {
$this->competences->add($competence);
$competence->setSubject($this);
}
return $this;
}
public function removeCompetence(Competence $competence): static
{
if ($this->competences->removeElement($competence)) {
// set the owning side to null (unless already changed)
if ($competence->getSubject() === $this) {
$competence->setSubject(null);
}
}
return $this;
}
/**
* @return Collection<int, WeekSubjectGoal>
*/
public function getWeekSubjectGoals(): Collection
{
return $this->weekSubjectGoals;
}
public function addWeekSubjectGoal(WeekSubjectGoal $weekSubjectGoal): static
{
if (!$this->weekSubjectGoals->contains($weekSubjectGoal)) {
$this->weekSubjectGoals->add($weekSubjectGoal);
$weekSubjectGoal->setSubject($this);
}
return $this;
}
public function removeWeekSubjectGoal(WeekSubjectGoal $weekSubjectGoal): static
{
if ($this->weekSubjectGoals->removeElement($weekSubjectGoal)) {
// set the owning side to null (unless already changed)
if ($weekSubjectGoal->getSubject() === $this) {
$weekSubjectGoal->setSubject(null);
}
}
return $this;
}
/**
* @return Collection<int, ProfSchoolPlanner>
*/
public function getProfSchoolPlanners(): Collection
{
return $this->profSchoolPlanners;
}
public function addProfSchoolPlanner(ProfSchoolPlanner $profSchoolPlanner): static
{
if (!$this->profSchoolPlanners->contains($profSchoolPlanner)) {
$this->profSchoolPlanners->add($profSchoolPlanner);
$profSchoolPlanner->setSubject($this);
}
return $this;
}
public function removeProfSchoolPlanner(ProfSchoolPlanner $profSchoolPlanner): static
{
if ($this->profSchoolPlanners->removeElement($profSchoolPlanner)) {
// set the owning side to null (unless already changed)
if ($profSchoolPlanner->getSubject() === $this) {
$profSchoolPlanner->setSubject(null);
}
}
return $this;
}
public function getLongitude(): ?float
{
return $this->longitude;
}
public function setLongitude(?float $longitude): static
{
$this->longitude = $longitude;
return $this;
}
public function getLatitude(): ?float
{
return $this->latitude;
}
public function setLatitude(?float $latitude): static
{
$this->latitude = $latitude;
return $this;
}
/**
* @return Collection<int, ProfTime>
*/
public function getProfTimes(): Collection
{
return $this->profTimes;
}
public function addProfTime(ProfTime $profTime): static
{
if (!$this->profTimes->contains($profTime)) {
$this->profTimes->add($profTime);
$profTime->setSubject($this);
}
return $this;
}
public function removeProfTime(ProfTime $profTime): static
{
if ($this->profTimes->removeElement($profTime)) {
// set the owning side to null (unless already changed)
if ($profTime->getSubject() === $this) {
$profTime->setSubject(null);
}
}
return $this;
}
}