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, orphanRemovaltrue)]
  45.     private Collection $studentScolarities;
  46.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'students')]
  47.     private ?Scolarity $scolarity null;
  48.     #[ORM\OneToMany(mappedBy'student'targetEntityScolarityHistory::class, orphanRemovaltrue)]
  49.     private Collection $scolarityHistories;
  50.     #[ORM\Column(length255nullabletrue)]
  51.     private ?string $slug null;
  52.     public function __construct()
  53.     {
  54.         $this->studentScolarities = new ArrayCollection();
  55.         $this->scolarityHystories = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getYear(): ?SchoolYear
  62.     {
  63.         return $this->year;
  64.     }
  65.     public function setYear(?SchoolYear $year): static
  66.     {
  67.         $this->year $year;
  68.         return $this;
  69.     }
  70.     public function getStudent(): ?Student
  71.     {
  72.         return $this->student;
  73.     }
  74.     public function setStudent(?Student $student): static
  75.     {
  76.         $this->student $student;
  77.         return $this;
  78.     }
  79.     public function getClasse(): ?TheClass
  80.     {
  81.         return $this->classe;
  82.     }
  83.     public function setClasse(?TheClass $classe): static
  84.     {
  85.         $this->classe $classe;
  86.         return $this;
  87.     }
  88.     /**
  89.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  90.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  91.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  92.      * must be able to accept an instance of 'File' as the bundle will inject one here
  93.      * during Doctrine hydration.
  94.      *
  95.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  96.      */
  97.     public function setImageFile(?File $imageFile null): void
  98.     {
  99.         $this->imageFile $imageFile;
  100.         if (null !== $imageFile) {
  101.             // It is required that at least one field changes if you are using doctrine
  102.             // otherwise the event listeners won't be called and the file is lost
  103.             $this->setUpdatedAt(new \DateTime());
  104.         }
  105.     }
  106.     public function getImageFile(): ?File
  107.     {
  108.         return $this->imageFile;
  109.     }
  110.     public function getImageName(): ?string
  111.     {
  112.         return $this->imageName;
  113.     }
  114.     public function setImageName(?string $imageName): static
  115.     {
  116.         $this->imageName $imageName;
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return Collection<int, StudentScolarity>
  121.      */
  122.     public function getStudentScolarities(): Collection
  123.     {
  124.         return $this->studentScolarities;
  125.     }
  126.     public function addStudentScolarity(StudentScolarity $studentScolarity): static
  127.     {
  128.         if (!$this->studentScolarities->contains($studentScolarity)) {
  129.             $this->studentScolarities->add($studentScolarity);
  130.             $studentScolarity->setStudent($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeStudentScolarity(StudentScolarity $studentScolarity): static
  135.     {
  136.         if ($this->studentScolarities->removeElement($studentScolarity)) {
  137.             // set the owning side to null (unless already changed)
  138.             if ($studentScolarity->getStudent() === $this) {
  139.                 $studentScolarity->setStudent(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144.     public function getScolarity(): ?Scolarity
  145.     {
  146.         return $this->scolarity;
  147.     }
  148.     public function setScolarity(?Scolarity $scolarity): static
  149.     {
  150.         $this->scolarity $scolarity;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return Collection<int, ScolarityHystory>
  155.      */
  156.     public function getScolarityHistories(): Collection
  157.     {
  158.         return $this->scolarityHistories;
  159.     }
  160.     public function addScolarityHistory(ScolarityHistory $scolarityHistory): static
  161.     {
  162.         if (!$this->scolarityHistories->contains($scolarityHistory)) {
  163.             $this->scolarityHistories->add($scolarityHistory);
  164.             $scolarityHistory->setStudent($this);
  165.         }
  166.         return $this;
  167.     }
  168.     public function removeScolarityHistory(ScolarityHistory $scolarityHistory): static
  169.     {
  170.         if ($this->scolarityHistories->removeElement($scolarityHistory)) {
  171.             // set the owning side to null (unless already changed)
  172.             if ($scolarityHistory->getStudent() === $this) {
  173.                 $scolarityHistory->setStudent(null);
  174.             }
  175.         }
  176.         return $this;
  177.     }
  178.     public function getSchool(): ?School
  179.     {
  180.         return $this->school;
  181.     }
  182.     public function setSchool(?School $school): static
  183.     {
  184.         $this->school $school;
  185.         return $this;
  186.     }
  187.     public function getSlug(): ?string
  188.     {
  189.         return $this->slug;
  190.     }
  191.     public function setSlug(?string $slug): static
  192.     {
  193.         $this->slug $slug;
  194.         return $this;
  195.     }
  196. }