<?php
namespace App\Entity;
use App\Repository\ScolarityHistoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: ScolarityHistoryRepository::class)]
class ScolarityHistory
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['getScolarityHistory', 'getScolarity'])]
private ?int $id = null;
#[ORM\ManyToMany(targetEntity: StudentScolarity::class, inversedBy: 'scolarityHistories', cascade: ["persist"])]
#[Groups(['getScolarityHistory'])]
private Collection $scolarities;
#[ORM\Column]
#[Groups(['getScolarityHistory', 'getScolarity'])]
private ?\DateTimeImmutable $paidAt = null;
#[ORM\Column(type: Types::ARRAY, nullable: true)]
#[Groups(['getScolarityHistory', 'getScolarity'])]
private ?array $amounts = null;
#[ORM\Column]
#[Groups(['getScolarityHistory', 'getScolarity'])]
private ?int $totalAmount = null;
#[ORM\ManyToOne(inversedBy: 'scolarityHistories')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['getScolarityHistory'])]
private ?StudentYear $student = null;
#[ORM\ManyToOne(inversedBy: 'scolarityHistories')]
private ?School $school = null;
#[ORM\ManyToOne(inversedBy: 'scolarityHistories')]
#[ORM\JoinColumn(nullable: false)]
private ?User $author = null;
#[ORM\ManyToOne(inversedBy: 'scolarityHistories')]
private ?User $editor = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\OneToMany(mappedBy: 'history', targetEntity: ScolarityHistoryEdition::class, orphanRemoval: true)]
private Collection $scolarityHistoryEditions;
#[ORM\Column(length: 255, nullable: true)]
private ?string $identifier = null;
public function __construct()
{
$this->scolarities = new ArrayCollection();
$this->scolarityHistoryEditions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, StudentScolarity>
*/
public function getScolarities(): Collection
{
return $this->scolarities;
}
public function addScolarity(StudentScolarity $scolarity): static
{
if (!$this->scolarities->contains($scolarity)) {
$this->scolarities->add($scolarity);
}
return $this;
}
public function removeScolarity(StudentScolarity $scolarity): static
{
$this->scolarities->removeElement($scolarity);
return $this;
}
public function getPaidAt(): ?\DateTimeImmutable
{
return $this->paidAt;
}
public function setPaidAt(\DateTimeImmutable $paidAt): static
{
$this->paidAt = $paidAt;
return $this;
}
public function getAmounts(): ?array
{
return $this->amounts;
}
public function setAmounts(?array $amounts): static
{
$this->amounts = $amounts;
return $this;
}
public function getTotalAmount(): ?int
{
return $this->totalAmount;
}
public function setTotalAmount(int $totalAmount): static
{
$this->totalAmount = $totalAmount;
return $this;
}
public function getStudent(): ?StudentYear
{
return $this->student;
}
public function setStudent(?StudentYear $student): static
{
$this->student = $student;
return $this;
}
public function getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
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 getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection<int, ScolarityHistoryEdition>
*/
public function getScolarityHistoryEditions(): Collection
{
return $this->scolarityHistoryEditions;
}
public function addScolarityHistoryEditon(ScolarityHistoryEdition $scolarityHistoryEdition): static
{
if (!$this->scolarityHistoryEditions->contains($scolarityHistoryEdition)) {
$this->scolarityHistoryEditions->add($scolarityHistoryEdition);
$scolarityHistoryEdition->setHistory($this);
}
return $this;
}
public function removeScolarityHistoryEdition(ScolarityHistoryEdition $scolarityHistoryEdition): static
{
if ($this->scolarityHistoryEditions->removeElement($scolarityHistoryEdition)) {
// set the owning side to null (unless already changed)
if ($scolarityHistoryEdition->getHistory() === $this) {
$scolarityHistoryEdition->setHistory(null);
}
}
return $this;
}
public function getIdentifier(): ?string
{
return $this->identifier;
}
public function setIdentifier(?string $identifier): static
{
$this->identifier = $identifier;
return $this;
}
}