<?php
namespace App\Entity;
use App\Entity\Traits\Timestampable;
use App\Repository\ParentNoteRepository;
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: ParentNoteRepository::class)]
class ParentNote
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['note'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['note'])]
private ?string $name = null;
#[ORM\ManyToOne(inversedBy: 'parentNotes')]
#[ORM\JoinColumn(nullable: false)]
private ?Exams $exam = null;
#[ORM\OneToMany(mappedBy: 'parentNote', targetEntity: Note::class, orphanRemoval: true)]
private Collection $note;
#[ORM\ManyToOne(inversedBy: 'parentNotes')]
#[ORM\JoinColumn(nullable: false)]
private ?Subject $subject = null;
#[ORM\ManyToOne(inversedBy: 'parentNotes')]
#[ORM\JoinColumn(nullable: false)]
private ?School $school = null;
#[ORM\ManyToOne(inversedBy: 'parentNotes')]
#[ORM\JoinColumn(nullable: false)]
private ?SchoolYear $year = null;
#[ORM\ManyToOne(inversedBy: 'parentNotes')]
#[ORM\JoinColumn(nullable: false)]
private ?TheClass $classe = null;
#[ORM\Column(nullable: true)]
#[Groups(['note'])]
private ?int $dividend = null;
public function __construct()
{
$this->note = 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 getExam(): ?Exams
{
return $this->exam;
}
public function setExam(?Exams $exam): static
{
$this->exam = $exam;
return $this;
}
/**
* @return Collection<int, Note>
*/
public function getNotes(): Collection
{
return $this->note;
}
public function addNote(Note $note): static
{
if (!$this->note->contains($note)) {
$this->note->add($note);
$note->setParentNote($this);
}
return $this;
}
public function removeNote(Note $note): static
{
if ($this->note->removeElement($note)) {
// set the owning side to null (unless already changed)
if ($note->getParentNote() === $this) {
$note->setParentNote(null);
}
}
return $this;
}
public function getSubject(): ?Subject
{
return $this->subject;
}
public function setSubject(?Subject $subject): static
{
$this->subject = $subject;
return $this;
}
public function getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
return $this;
}
public function getYear(): ?SchoolYear
{
return $this->year;
}
public function setYear(?SchoolYear $year): static
{
$this->year = $year;
return $this;
}
public function getClasse(): ?TheClass
{
return $this->classe;
}
public function setClasse(?TheClass $classe): static
{
$this->classe = $classe;
return $this;
}
public function getDividend(): ?int
{
return $this->dividend;
}
public function setDividend(?int $dividend): static
{
$this->dividend = $dividend;
return $this;
}
}