<?php
namespace App\Entity;
use App\Entity\Traits\Timestampable;
use App\Repository\NoteRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: NoteRepository::class)]
#[ORM\UniqueConstraint(columns: ['student_id', 'subject_id', 'exams_id', 'parent_note_id'])]
class Note
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['note','getBulletin'])]
private ?int $id = null;
#[ORM\Column]
#[Groups(['note','getBulletin'])]
private ?float $note = null;
#[ORM\Column]
#[Groups(['note','getBulletin'])]
private ?float $noteCoef = null;
#[ORM\ManyToOne(inversedBy: 'notes', cascade: ["persist"])]
#[Groups(['note'])]
private ?Student $student = null;
#[ORM\ManyToOne(inversedBy: 'notes', cascade: ["persist"])]
#[Groups(['note'])]
private ?Exams $exams = null;
#[ORM\ManyToOne(inversedBy: 'notes', cascade: ["persist"])]
#[Groups(['note'])]
private ?TheClass $classe = null;
#[ORM\ManyToOne(inversedBy: 'notes', cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['note','getBulletin'])]
private ?Subject $subject = null;
#[ORM\ManyToOne(inversedBy: 'notes', cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
private ?SchoolYear $year = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['note'])]
private ?string $examName = null;
#[ORM\ManyToOne(inversedBy: 'notes', cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
private ?User $author = null;
#[ORM\ManyToOne(inversedBy: 'notesEdited', cascade: ["persist"])]
private ?User $editor = null;
#[ORM\ManyToOne(inversedBy: 'notes', cascade: ["persist"])]
private ?School $school = null;
#[ORM\ManyToOne(inversedBy: 'notes')]
private ?SubSequence $subSequence = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['note'])]
private ?string $name = null;
#[ORM\ManyToOne(inversedBy: 'note')]
#[Groups(['note'])]
private ?ParentNote $parentNote = null;
#[ORM\Column(nullable: true)]
private ?int $division = null;
#[ORM\Column(nullable: true)]
#[Groups(['note'])]
private ?int $dividend = null;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: SubNote::class)]
private Collection $subNotes;
public function __construct()
{
$this->subNotes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNote(): ?float
{
return $this->note;
}
public function setNote(float $note): static
{
$this->note = $note;
return $this;
}
public function getNoteCoef(): ?float
{
return $this->noteCoef;
}
public function setNoteCoef(float $noteCoef): static
{
$this->noteCoef = $noteCoef;
return $this;
}
public function getStudent(): ?Student
{
return $this->student;
}
public function setStudent(?Student $student): static
{
$this->student = $student;
return $this;
}
public function getExams(): ?Exams
{
return $this->exams;
}
public function setExams(?Exams $exams): static
{
$this->exams = $exams;
return $this;
}
public function getClasse(): ?TheClass
{
return $this->classe;
}
public function setClasse(?TheClass $classe): static
{
$this->classe = $classe;
return $this;
}
public function getSubject(): ?Subject
{
return $this->subject;
}
public function setSubject(?Subject $subject): static
{
$this->subject = $subject;
return $this;
}
public function getYear(): ?SchoolYear
{
return $this->year;
}
public function setYear(?SchoolYear $year): static
{
$this->year = $year;
return $this;
}
public function getExamName(): ?string
{
return $this->examName;
}
public function setExamName(?string $examName): static
{
$this->examName = $examName;
return $this;
}
public function getRelation(): ?string
{
return $this->relation;
}
public function setRelation(string $relation): static
{
$this->relation = $relation;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): static
{
$this->author = $author;
return $this;
}
public function getEditor(): ?User
{
return $this->editor;
}
public function setEditor(?User $editor): static
{
$this->editor = $editor;
return $this;
}
public function getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
return $this;
}
public function getSubSequence(): ?SubSequence
{
return $this->subSequence;
}
public function setSubSequence(?SubSequence $subSequence): static
{
$this->subSequence = $subSequence;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
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->setParent($this);
}
return $this;
}
public function getParentNote(): ?ParentNote
{
return $this->parentNote;
}
public function setParentNote(?ParentNote $parentNote): static
{
$this->parentNote = $parentNote;
return $this;
}
public function getDivision(): ?int
{
return $this->division;
}
public function setDivision(?int $division): static
{
$this->division = $division;
return $this;
}
public function getDividend(): ?int
{
return $this->dividend;
}
public function setDividend(?int $dividend): static
{
$this->dividend = $dividend;
return $this;
}
public function removeSubNote(SubNote $subNote): static
{
if ($this->subNotes->removeElement($subNote)) {
// set the owning side to null (unless already changed)
if ($subNote->getParent() === $this) {
$subNote->setParent(null);
}
}
return $this;
}
}