src/Entity/StudentYear.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StudentYearRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use App\Entity\Traits\Timestampable;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  11. use JMS\Serializer\Annotation\Groups;
  12. #[ORM\HasLifecycleCallbacks]
  13. #[Vich\Uploadable]
  14. #[ORM\Entity(repositoryClassStudentYearRepository::class)]
  15. class StudentYear
  16. {
  17.     use Timestampable;
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     #[Groups(['getStudents'])]
  22.     private ?int $id null;
  23.     #[ORM\ManyToOne(inversedBy'studentYears'cascade: ["persist"])]
  24.     #[Groups(['getStudents'])]
  25.     private ?SchoolYear $year null;
  26.     #[ORM\ManyToOne(inversedBy'studentYears'cascade: ["persist"])]
  27.     #[Groups(['getStudents','getExamStudent'])]
  28.     private ?Student $student null;
  29.   /**
  30.     * NOTE: This is not a mapped field of entity metadata, just a simple property.
  31.     *
  32.    */
  33.    #[Vich\UploadableField(mapping'student_profile'fileNameProperty'imageName')]
  34.    private ?File $imageFile null;
  35.    #[ORM\Column(length255nullabletrue)]
  36.    private ?string $imageName null;
  37.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'studentYears')]
  38.     #[ORM\JoinColumn(nullablefalse)]
  39.     #[Groups(['getStudents','getExamStudent'])]
  40.     private ?TheClass $classe null;
  41.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'studentYears')]
  42.     #[Groups(['getStudents'])]
  43.     private ?School $school null;
  44.     #[ORM\OneToMany(mappedBy'student'targetEntityStudentScolarity::class)]
  45.     private Collection $studentScolarities;
  46.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'students')]
  47.     private ?Scolarity $scolarity null;
  48.     #[ORM\OneToMany(mappedBy'student'targetEntityScolarityHistory::class)]
  49.     private Collection $scolarityHistories;
  50.     #[ORM\Column(length255nullabletrue)]
  51.     private ?string $slug null;
  52.     #[ORM\Column(length255nullabletrue)]
  53.     private ?string $lastSchoolName null;
  54.     #[ORM\Column(nullabletrue)]
  55.     private ?bool $repeater null;
  56.     #[ORM\Column(type'boolean'options: ['default' => true])]
  57.     private ?bool $active null;
  58.     public function __construct()
  59.     {
  60.         $this->active true;
  61.         $this->studentScolarities = new ArrayCollection();
  62.         $this->scolarityHistories = new ArrayCollection();
  63.     }
  64.     public function getId(): ?int
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getYear(): ?SchoolYear
  69.     {
  70.         return $this->year;
  71.     }
  72.     public function setYear(?SchoolYear $year): static
  73.     {
  74.         $this->year $year;
  75.         return $this;
  76.     }
  77.     public function getStudent(): ?Student
  78.     {
  79.         return $this->student;
  80.     }
  81.     public function setStudent(?Student $student): static
  82.     {
  83.         $this->student $student;
  84.         return $this;
  85.     }
  86.     public function getClasse(): ?TheClass
  87.     {
  88.         return $this->classe;
  89.     }
  90.     public function setClasse(?TheClass $classe): static
  91.     {
  92.         $this->classe $classe;
  93.         return $this;
  94.     }
  95.     /**
  96.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  97.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  98.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  99.      * must be able to accept an instance of 'File' as the bundle will inject one here
  100.      * during Doctrine hydration.
  101.      *
  102.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  103.      */
  104.     public function setImageFile(?File $imageFile null): void
  105.     {
  106.         $this->imageFile $imageFile;
  107.         if (null !== $imageFile) {
  108.             // It is required that at least one field changes if you are using doctrine
  109.             // otherwise the event listeners won't be called and the file is lost
  110.             $this->setUpdatedAt(new \DateTime());
  111.         }
  112.     }
  113.     public function getImageFile(): ?File
  114.     {
  115.         return $this->imageFile;
  116.     }
  117.     public function getImageName(): ?string
  118.     {
  119.         return $this->imageName;
  120.     }
  121.     public function setImageName(?string $imageName): static
  122.     {
  123.         $this->imageName $imageName;
  124.         return $this;
  125.     }
  126.     /**
  127.      * @return Collection<int, StudentScolarity>
  128.      */
  129.     public function getStudentScolarities(): Collection
  130.     {
  131.         return $this->studentScolarities;
  132.     }
  133.     public function addStudentScolarity(StudentScolarity $studentScolarity): static
  134.     {
  135.         if (!$this->studentScolarities->contains($studentScolarity)) {
  136.             $this->studentScolarities->add($studentScolarity);
  137.             $studentScolarity->setStudent($this);
  138.         }
  139.         return $this;
  140.     }
  141.     public function removeStudentScolarity(StudentScolarity $studentScolarity): static
  142.     {
  143.         if ($this->studentScolarities->removeElement($studentScolarity)) {
  144.             // set the owning side to null (unless already changed)
  145.             if ($studentScolarity->getStudent() === $this) {
  146.                 $studentScolarity->setStudent(null);
  147.             }
  148.         }
  149.         return $this;
  150.     }
  151.     public function getScolarity(): ?Scolarity
  152.     {
  153.         return $this->scolarity;
  154.     }
  155.     public function setScolarity(?Scolarity $scolarity): static
  156.     {
  157.         $this->scolarity $scolarity;
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection<int, ScolarityHystory>
  162.      */
  163.     public function getScolarityHistories(): Collection
  164.     {
  165.         return $this->scolarityHistories;
  166.     }
  167.     public function addScolarityHistory(ScolarityHistory $scolarityHistory): static
  168.     {
  169.         if (!$this->scolarityHistories->contains($scolarityHistory)) {
  170.             $this->scolarityHistories->add($scolarityHistory);
  171.             $scolarityHistory->setStudent($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeScolarityHistory(ScolarityHistory $scolarityHistory): static
  176.     {
  177.         if ($this->scolarityHistories->removeElement($scolarityHistory)) {
  178.             // set the owning side to null (unless already changed)
  179.             if ($scolarityHistory->getStudent() === $this) {
  180.                 $scolarityHistory->setStudent(null);
  181.             }
  182.         }
  183.         return $this;
  184.     }
  185.     public function getSchool(): ?School
  186.     {
  187.         return $this->school;
  188.     }
  189.     public function setSchool(?School $school): static
  190.     {
  191.         $this->school $school;
  192.         return $this;
  193.     }
  194.     public function getSlug(): ?string
  195.     {
  196.         return $this->slug;
  197.     }
  198.     public function setSlug(?string $slug): static
  199.     {
  200.         $this->slug $slug;
  201.         return $this;
  202.     }
  203.     public function getLastSchoolName(): ?string
  204.     {
  205.         return $this->lastSchoolName;
  206.     }
  207.     public function setLastSchoolName(?string $lastSchoolName): static
  208.     {
  209.         $this->lastSchoolName $lastSchoolName;
  210.         return $this;
  211.     }
  212.     public function isRepeater(): ?bool
  213.     {
  214.         return $this->repeater;
  215.     }
  216.     public function setRepeater(?bool $repeater): static
  217.     {
  218.         $this->repeater $repeater;
  219.         return $this;
  220.     }
  221.     public function isActive(): ?bool
  222.     {
  223.         return $this->active;
  224.     }
  225.     public function setActive(bool $active): static
  226.     {
  227.         $this->active $active;
  228.         return $this;
  229.     }
  230. }