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->studentScolarities = new ArrayCollection();
  61.         $this->scolarityHystories = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getYear(): ?SchoolYear
  68.     {
  69.         return $this->year;
  70.     }
  71.     public function setYear(?SchoolYear $year): static
  72.     {
  73.         $this->year $year;
  74.         return $this;
  75.     }
  76.     public function getStudent(): ?Student
  77.     {
  78.         return $this->student;
  79.     }
  80.     public function setStudent(?Student $student): static
  81.     {
  82.         $this->student $student;
  83.         return $this;
  84.     }
  85.     public function getClasse(): ?TheClass
  86.     {
  87.         return $this->classe;
  88.     }
  89.     public function setClasse(?TheClass $classe): static
  90.     {
  91.         $this->classe $classe;
  92.         return $this;
  93.     }
  94.     /**
  95.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  96.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  97.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  98.      * must be able to accept an instance of 'File' as the bundle will inject one here
  99.      * during Doctrine hydration.
  100.      *
  101.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  102.      */
  103.     public function setImageFile(?File $imageFile null): void
  104.     {
  105.         $this->imageFile $imageFile;
  106.         if (null !== $imageFile) {
  107.             // It is required that at least one field changes if you are using doctrine
  108.             // otherwise the event listeners won't be called and the file is lost
  109.             $this->setUpdatedAt(new \DateTime());
  110.         }
  111.     }
  112.     public function getImageFile(): ?File
  113.     {
  114.         return $this->imageFile;
  115.     }
  116.     public function getImageName(): ?string
  117.     {
  118.         return $this->imageName;
  119.     }
  120.     public function setImageName(?string $imageName): static
  121.     {
  122.         $this->imageName $imageName;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return Collection<int, StudentScolarity>
  127.      */
  128.     public function getStudentScolarities(): Collection
  129.     {
  130.         return $this->studentScolarities;
  131.     }
  132.     public function addStudentScolarity(StudentScolarity $studentScolarity): static
  133.     {
  134.         if (!$this->studentScolarities->contains($studentScolarity)) {
  135.             $this->studentScolarities->add($studentScolarity);
  136.             $studentScolarity->setStudent($this);
  137.         }
  138.         return $this;
  139.     }
  140.     public function removeStudentScolarity(StudentScolarity $studentScolarity): static
  141.     {
  142.         if ($this->studentScolarities->removeElement($studentScolarity)) {
  143.             // set the owning side to null (unless already changed)
  144.             if ($studentScolarity->getStudent() === $this) {
  145.                 $studentScolarity->setStudent(null);
  146.             }
  147.         }
  148.         return $this;
  149.     }
  150.     public function getScolarity(): ?Scolarity
  151.     {
  152.         return $this->scolarity;
  153.     }
  154.     public function setScolarity(?Scolarity $scolarity): static
  155.     {
  156.         $this->scolarity $scolarity;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, ScolarityHystory>
  161.      */
  162.     public function getScolarityHistories(): Collection
  163.     {
  164.         return $this->scolarityHistories;
  165.     }
  166.     public function addScolarityHistory(ScolarityHistory $scolarityHistory): static
  167.     {
  168.         if (!$this->scolarityHistories->contains($scolarityHistory)) {
  169.             $this->scolarityHistories->add($scolarityHistory);
  170.             $scolarityHistory->setStudent($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeScolarityHistory(ScolarityHistory $scolarityHistory): static
  175.     {
  176.         if ($this->scolarityHistories->removeElement($scolarityHistory)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($scolarityHistory->getStudent() === $this) {
  179.                 $scolarityHistory->setStudent(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     public function getSchool(): ?School
  185.     {
  186.         return $this->school;
  187.     }
  188.     public function setSchool(?School $school): static
  189.     {
  190.         $this->school $school;
  191.         return $this;
  192.     }
  193.     public function getSlug(): ?string
  194.     {
  195.         return $this->slug;
  196.     }
  197.     public function setSlug(?string $slug): static
  198.     {
  199.         $this->slug $slug;
  200.         return $this;
  201.     }
  202.     public function getLastSchoolName(): ?string
  203.     {
  204.         return $this->lastSchoolName;
  205.     }
  206.     public function setLastSchoolName(?string $lastSchoolName): static
  207.     {
  208.         $this->lastSchoolName $lastSchoolName;
  209.         return $this;
  210.     }
  211.     public function isRepeater(): ?bool
  212.     {
  213.         return $this->repeater;
  214.     }
  215.     public function setRepeater(?bool $repeater): static
  216.     {
  217.         $this->repeater $repeater;
  218.         return $this;
  219.     }
  220.     public function isActive(): ?bool
  221.     {
  222.         return $this->active;
  223.     }
  224.     public function setActive(bool $active): static
  225.     {
  226.         $this->active $active;
  227.         return $this;
  228.     }
  229. }