src/Entity/GlobalExam.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\GlobalExamRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Traits\Timestampable;
  8. use JMS\Serializer\Annotation\Groups;
  9. #[ORM\HasLifecycleCallbacks]
  10. #[ORM\Entity(repositoryClassGlobalExamRepository::class)]
  11. class GlobalExam
  12. {
  13.     use Timestampable;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $name null;
  20.     #[ORM\ManyToOne(inversedBy'globalExams')]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?School $school null;
  23.     #[ORM\OneToMany(mappedBy'globalExam'targetEntityExams::class, orphanRemovaltrue)]
  24.     private Collection $exams;
  25.     public function __construct()
  26.     {
  27.         $this->exams = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getName(): ?string
  34.     {
  35.         return $this->name;
  36.     }
  37.     public function setName(string $name): static
  38.     {
  39.         $this->name $name;
  40.         return $this;
  41.     }
  42.     public function getSchool(): ?School
  43.     {
  44.         return $this->school;
  45.     }
  46.     public function setSchool(?School $school): static
  47.     {
  48.         $this->school $school;
  49.         return $this;
  50.     }
  51.     /**
  52.      * @return Collection<int, Exams>
  53.      */
  54.     public function getExams(): Collection
  55.     {
  56.         return $this->exams;
  57.     }
  58.     public function addExam(Exams $exam): static
  59.     {
  60.         if (!$this->exams->contains($exam)) {
  61.             $this->exams->add($exam);
  62.             $exam->setGlobalExam($this);
  63.         }
  64.         return $this;
  65.     }
  66.     public function removeExam(Exams $exam): static
  67.     {
  68.         if ($this->exams->removeElement($exam)) {
  69.             // set the owning side to null (unless already changed)
  70.             if ($exam->getGlobalExam() === $this) {
  71.                 $exam->setGlobalExam(null);
  72.             }
  73.         }
  74.         return $this;
  75.     }
  76. }