<?php
namespace App\Entity;
use App\Repository\ScolarityRepository;
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: ScolarityRepository::class)]
class Scolarity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['getScolarity', 'getScolarityHistory'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['getScolarity', 'getScolarityHistory'])]
private ?string $name = null;
#[ORM\ManyToOne(inversedBy: 'scolarities', cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['getScolarity'])]
private ?TheClass $classe = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['getScolarity'])]
private ?\DateTimeInterface $endAt = null;
#[ORM\ManyToOne(inversedBy: 'scolarities', cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
private ?SchoolYear $year = null;
#[ORM\ManyToOne(inversedBy: 'scolarities', cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
private ?User $author = null;
#[ORM\OneToMany(mappedBy: 'scolarity', targetEntity: StudentScolarity::class)]
private Collection $studentScolarities;
#[ORM\OneToMany(mappedBy: 'scolarity', targetEntity: StudentYear::class)]
private Collection $students;
#[ORM\Column(type: 'boolean')]
#[Groups(['getScolarity'])]
private ?bool $isExams = false;
#[ORM\Column]
#[Groups(['getScolarity'])]
private ?int $amount = null;
#[ORM\ManyToOne(inversedBy: 'scolarities')]
private ?School $school = null;
public function __construct()
{
$this->studentScolarities = new ArrayCollection();
$this->students = 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 getClasse(): ?TheClass
{
return $this->classe;
}
public function setClasse(?TheClass $classe): static
{
$this->classe = $classe;
return $this;
}
public function getEndAt(): ?\DateTimeInterface
{
return $this->endAt;
}
public function setEndAt(\DateTimeInterface $endAt): static
{
$this->endAt = $endAt;
return $this;
}
public function getYear(): ?SchoolYear
{
return $this->year;
}
public function setYear(?SchoolYear $year): static
{
$this->year = $year;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): static
{
$this->author = $author;
return $this;
}
/**
* @return Collection<int, StudentScolarity>
*/
public function getStudentScolarities(): Collection
{
return $this->studentScolarities;
}
public function addStudentScolarity(StudentScolarity $studentScolarity): static
{
if (!$this->studentScolarities->contains($studentScolarity)) {
$this->studentScolarities->add($studentScolarity);
$studentScolarity->setScolarity($this);
}
return $this;
}
public function removeStudentScolarity(StudentScolarity $studentScolarity): static
{
if ($this->studentScolarities->removeElement($studentScolarity)) {
// set the owning side to null (unless already changed)
if ($studentScolarity->getScolarity() === $this) {
$studentScolarity->setScolarity(null);
}
}
return $this;
}
/**
* @return Collection<int, StudentYear>
*/
public function getStudents(): Collection
{
return $this->students;
}
public function addStudent(StudentYear $student): static
{
if (!$this->students->contains($student)) {
$this->students->add($student);
$student->setScolarity($this);
}
return $this;
}
public function removeStudent(StudentYear $student): static
{
if ($this->students->removeElement($student)) {
// set the owning side to null (unless already changed)
if ($student->getScolarity() === $this) {
$student->setScolarity(null);
}
}
return $this;
}
public function isIsExams(): ?bool
{
return $this->isExams;
}
public function setIsExams(?bool $isExams): static
{
$this->isExams = $isExams;
return $this;
}
public function getAmount(): ?int
{
return $this->amount;
}
public function setAmount(int $amount): static
{
$this->amount = $amount;
return $this;
}
public function getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
return $this;
}
}