<?php
namespace App\Entity;
use App\Repository\GlobalExamRepository;
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: GlobalExamRepository::class)]
class GlobalExam
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\ManyToOne(inversedBy: 'globalExams')]
#[ORM\JoinColumn(nullable: false)]
private ?School $school = null;
#[ORM\OneToMany(mappedBy: 'globalExam', targetEntity: Exams::class, orphanRemoval: true)]
private Collection $exams;
public function __construct()
{
$this->exams = 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 getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
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->setGlobalExam($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->getGlobalExam() === $this) {
$exam->setGlobalExam(null);
}
}
return $this;
}
}