src/Entity/Student.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StudentRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. /**
  8.  * @ORM\Entity(repositoryClass=StudentRepository::class)
  9.  */
  10. class Student
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $firstName;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $lastName;
  26.     /**
  27.      * @ORM\Column(type="boolean")
  28.      */
  29.     private $gender;
  30.     /**
  31.      * @ORM\Column(type="date")
  32.      */
  33.     private $birthDate;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $address;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $phone;
  42.     /**
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      */
  45.     private $email;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $fatherName;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private $fatherPhone;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $motherName;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $motherPhone;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $guardianName;
  66.     /**
  67.      * @ORM\Column(type="string", length=255, nullable=true)
  68.      */
  69.     private $guardianPhone;
  70.     /**
  71.      * @ORM\Column(type="string", length=255, nullable=true)
  72.      */
  73.     private $guardianLegalRelationship;
  74.     /**
  75.      * @ORM\Column(type="string", length=255, nullable=true)
  76.      */
  77.     private $postName;
  78.     /**
  79.      * @ORM\Column(type="string", length=255, nullable=true)
  80.      */
  81.     private $birthPlace;
  82.     /**
  83.      * @ORM\Column(type="string", length=255, nullable=true)
  84.      */
  85.     private $nationality;
  86.     /**
  87.      * @ORM\Column(type="text", nullable=true)
  88.      */
  89.     private $languages;
  90.     /**
  91.      * @ORM\Column(type="string", length=255, nullable=true)
  92.      */
  93.     private $addressNumber;
  94.     /**
  95.      * @ORM\Column(type="string", length=255, nullable=true)
  96.      */
  97.     private $addressAvenue;
  98.     /**
  99.      * @ORM\Column(type="string", length=255, nullable=true)
  100.      */
  101.     private $addressDistrict;
  102.     /**
  103.      * @ORM\Column(type="string", length=255, nullable=true)
  104.      */
  105.     private $addressCommune;
  106.     /**
  107.      * @ORM\Column(type="string", length=255, nullable=true)
  108.      */
  109.     private $previousSchool;
  110.     /**
  111.      * @ORM\Column(type="string", length=255, nullable=true)
  112.      */
  113.     private $previousClass;
  114.     /**
  115.      * @ORM\Column(type="string", length=255, nullable=true)
  116.      */
  117.     private $previousSchoolContact;
  118.     /**
  119.      * @ORM\Column(type="string", length=255, nullable=true)
  120.      */
  121.     private $originDistrict;
  122.     /**
  123.      * @ORM\Column(type="string", length=255, nullable=true)
  124.      */
  125.     private $originTerritory;
  126.     /**
  127.      * @ORM\Column(type="string", length=255, nullable=true)
  128.      */
  129.     private $originSector;
  130.     /**
  131.      * @ORM\Column(type="string", length=255, nullable=true)
  132.      */
  133.     private $originProvince;
  134.     /**
  135.      * @ORM\Column(type="text", nullable=true)
  136.      */
  137.     private $healthInfo;
  138.     /**
  139.      * @ORM\ManyToOne(targetEntity=School::class, inversedBy="students")
  140.      * @ORM\JoinColumn(nullable=false)
  141.      */
  142.     private $school;
  143.     /**
  144.      * @ORM\Column(type="datetime_immutable")
  145.      */
  146.     private $createdAt;
  147.     /**
  148.      * @ORM\Column(type="datetime_immutable", nullable=true)
  149.      */
  150.     private $updatedAt;
  151.     /**
  152.      * @ORM\ManyToOne(targetEntity=Promotion::class, inversedBy="students")
  153.      * @ORM\JoinColumn(nullable=true)
  154.      */
  155.     private $promotion;
  156.     /**
  157.      * @ORM\OneToMany(targetEntity=Payment::class, mappedBy="student")
  158.      */
  159.     private $payments;
  160.     /**
  161.      * @ORM\OneToMany(targetEntity=Attendance::class, mappedBy="student")
  162.      */
  163.     private $attendances;
  164.     public function __construct()
  165.     {
  166.         $this->payments = new ArrayCollection();
  167.     }
  168.     public function __toString(): string
  169.     {
  170.         return $this->firstName ' ' $this->lastName;
  171.     }
  172.     public function getId(): ?int
  173.     {
  174.         return $this->id;
  175.     }
  176.     public function getFirstName(): ?string
  177.     {
  178.         return $this->firstName;
  179.     }
  180.     public function setFirstName(string $firstName): self
  181.     {
  182.         $this->firstName $firstName;
  183.         return $this;
  184.     }
  185.     public function getLastName(): ?string
  186.     {
  187.         return $this->lastName;
  188.     }
  189.     public function setLastName(string $lastName): self
  190.     {
  191.         $this->lastName $lastName;
  192.         return $this;
  193.     }
  194.     public function getGender(): ?bool
  195.     {
  196.         return $this->gender;
  197.     }
  198.     public function setGender(bool $gender): self
  199.     {
  200.         $this->gender $gender;
  201.         return $this;
  202.     }
  203.     public function getBirthDate(): ?\DateTimeInterface
  204.     {
  205.         return $this->birthDate;
  206.     }
  207.     public function setBirthDate(\DateTimeInterface $birthDate): self
  208.     {
  209.         $this->birthDate $birthDate;
  210.         return $this;
  211.     }
  212.     public function getAddress(): ?string
  213.     {
  214.         return $this->address;
  215.     }
  216.     public function setAddress(?string $address): self
  217.     {
  218.         $this->address $address;
  219.         return $this;
  220.     }
  221.     public function getPhone(): ?string
  222.     {
  223.         return $this->phone;
  224.     }
  225.     public function setPhone(?string $phone): self
  226.     {
  227.         $this->phone $phone;
  228.         return $this;
  229.     }
  230.     public function getEmail(): ?string
  231.     {
  232.         return $this->email;
  233.     }
  234.     public function setEmail(?string $email): self
  235.     {
  236.         $this->email $email;
  237.         return $this;
  238.     }
  239.     public function getFatherName(): ?string
  240.     {
  241.         return $this->fatherName;
  242.     }
  243.     public function setFatherName(?string $fatherName): self
  244.     {
  245.         $this->fatherName $fatherName;
  246.         return $this;
  247.     }
  248.     public function getFatherPhone(): ?string
  249.     {
  250.         return $this->fatherPhone;
  251.     }
  252.     public function setFatherPhone(?string $fatherPhone): self
  253.     {
  254.         $this->fatherPhone $fatherPhone;
  255.         return $this;
  256.     }
  257.     public function getMotherName(): ?string
  258.     {
  259.         return $this->motherName;
  260.     }
  261.     public function setMotherName(?string $motherName): self
  262.     {
  263.         $this->motherName $motherName;
  264.         return $this;
  265.     }
  266.     public function getMotherPhone(): ?string
  267.     {
  268.         return $this->motherPhone;
  269.     }
  270.     public function setMotherPhone(?string $motherPhone): self
  271.     {
  272.         $this->motherPhone $motherPhone;
  273.         return $this;
  274.     }
  275.     public function getGuardianName(): ?string
  276.     {
  277.         return $this->guardianName;
  278.     }
  279.     public function setGuardianName(?string $guardianName): self
  280.     {
  281.         $this->guardianName $guardianName;
  282.         return $this;
  283.     }
  284.     public function getGuardianPhone(): ?string
  285.     {
  286.         return $this->guardianPhone;
  287.     }
  288.     public function setGuardianPhone(?string $guardianPhone): self
  289.     {
  290.         $this->guardianPhone $guardianPhone;
  291.         return $this;
  292.     }
  293.     public function getGuardianLegalRelationship(): ?string
  294.     {
  295.         return $this->guardianLegalRelationship;
  296.     }
  297.     public function setGuardianLegalRelationship(?string $guardianLegalRelationship): self
  298.     {
  299.         $this->guardianLegalRelationship $guardianLegalRelationship;
  300.         return $this;
  301.     }
  302.     public function getPostName(): ?string
  303.     {
  304.         return $this->postName;
  305.     }
  306.     public function setPostName(?string $postName): self
  307.     {
  308.         $this->postName $postName;
  309.         return $this;
  310.     }
  311.     public function getBirthPlace(): ?string
  312.     {
  313.         return $this->birthPlace;
  314.     }
  315.     public function setBirthPlace(?string $birthPlace): self
  316.     {
  317.         $this->birthPlace $birthPlace;
  318.         return $this;
  319.     }
  320.     public function getNationality(): ?string
  321.     {
  322.         return $this->nationality;
  323.     }
  324.     public function setNationality(?string $nationality): self
  325.     {
  326.         $this->nationality $nationality;
  327.         return $this;
  328.     }
  329.     public function getLanguages(): ?string
  330.     {
  331.         return $this->languages;
  332.     }
  333.     public function setLanguages(?string $languages): self
  334.     {
  335.         $this->languages $languages;
  336.         return $this;
  337.     }
  338.     public function getAddressNumber(): ?string
  339.     {
  340.         return $this->addressNumber;
  341.     }
  342.     public function setAddressNumber(?string $addressNumber): self
  343.     {
  344.         $this->addressNumber $addressNumber;
  345.         return $this;
  346.     }
  347.     public function getAddressAvenue(): ?string
  348.     {
  349.         return $this->addressAvenue;
  350.     }
  351.     public function setAddressAvenue(?string $addressAvenue): self
  352.     {
  353.         $this->addressAvenue $addressAvenue;
  354.         return $this;
  355.     }
  356.     public function getAddressDistrict(): ?string
  357.     {
  358.         return $this->addressDistrict;
  359.     }
  360.     public function setAddressDistrict(?string $addressDistrict): self
  361.     {
  362.         $this->addressDistrict $addressDistrict;
  363.         return $this;
  364.     }
  365.     public function getAddressCommune(): ?string
  366.     {
  367.         return $this->addressCommune;
  368.     }
  369.     public function setAddressCommune(?string $addressCommune): self
  370.     {
  371.         $this->addressCommune $addressCommune;
  372.         return $this;
  373.     }
  374.     public function getPreviousSchool(): ?string
  375.     {
  376.         return $this->previousSchool;
  377.     }
  378.     public function setPreviousSchool(?string $previousSchool): self
  379.     {
  380.         $this->previousSchool $previousSchool;
  381.         return $this;
  382.     }
  383.     public function getPreviousClass(): ?string
  384.     {
  385.         return $this->previousClass;
  386.     }
  387.     public function setPreviousClass(?string $previousClass): self
  388.     {
  389.         $this->previousClass $previousClass;
  390.         return $this;
  391.     }
  392.     public function getPreviousSchoolContact(): ?string
  393.     {
  394.         return $this->previousSchoolContact;
  395.     }
  396.     public function setPreviousSchoolContact(?string $previousSchoolContact): self
  397.     {
  398.         $this->previousSchoolContact $previousSchoolContact;
  399.         return $this;
  400.     }
  401.     public function getOriginDistrict(): ?string
  402.     {
  403.         return $this->originDistrict;
  404.     }
  405.     public function setOriginDistrict(?string $originDistrict): self
  406.     {
  407.         $this->originDistrict $originDistrict;
  408.         return $this;
  409.     }
  410.     public function getOriginTerritory(): ?string
  411.     {
  412.         return $this->originTerritory;
  413.     }
  414.     public function setOriginTerritory(?string $originTerritory): self
  415.     {
  416.         $this->originTerritory $originTerritory;
  417.         return $this;
  418.     }
  419.     public function getOriginSector(): ?string
  420.     {
  421.         return $this->originSector;
  422.     }
  423.     public function setOriginSector(?string $originSector): self
  424.     {
  425.         $this->originSector $originSector;
  426.         return $this;
  427.     }
  428.     public function getOriginProvince(): ?string
  429.     {
  430.         return $this->originProvince;
  431.     }
  432.     public function setOriginProvince(?string $originProvince): self
  433.     {
  434.         $this->originProvince $originProvince;
  435.         return $this;
  436.     }
  437.     public function getHealthInfo(): ?string
  438.     {
  439.         return $this->healthInfo;
  440.     }
  441.     public function setHealthInfo(?string $healthInfo): self
  442.     {
  443.         $this->healthInfo $healthInfo;
  444.         return $this;
  445.     }
  446.     public function getSchool(): ?School
  447.     {
  448.         return $this->school;
  449.     }
  450.     public function setSchool(?School $school): self
  451.     {
  452.         $this->school $school;
  453.         return $this;
  454.     }
  455.     public function getCreatedAt(): ?\DateTimeImmutable
  456.     {
  457.         return $this->createdAt;
  458.     }
  459.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  460.     {
  461.         $this->createdAt $createdAt;
  462.         return $this;
  463.     }
  464.     public function getUpdatedAt(): ?\DateTimeImmutable
  465.     {
  466.         return $this->updatedAt;
  467.     }
  468.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  469.     {
  470.         $this->updatedAt $updatedAt;
  471.         return $this;
  472.     }
  473.     public function getPromotion(): ?Promotion
  474.     {
  475.         return $this->promotion;
  476.     }
  477.     public function setPromotion(?Promotion $promotion): self
  478.     {
  479.         $this->promotion $promotion;
  480.         return $this;
  481.     }
  482.     /**
  483.      * @return Collection<int, Payment>
  484.      */
  485.     public function getPayments(): Collection
  486.     {
  487.         return $this->payments;
  488.     }
  489.     public function addPayment(Payment $payment): self
  490.     {
  491.         if (!$this->payments->contains($payment)) {
  492.             $this->payments->add($payment);
  493.             $payment->setStudent($this);
  494.         }
  495.         return $this;
  496.     }
  497.     public function removePayment(Payment $payment): self
  498.     {
  499.         if ($this->payments->removeElement($payment)) {
  500.             // set the owning side to null (unless already changed)
  501.             if ($payment->getStudent() === $this) {
  502.                 $payment->setStudent(null);
  503.             }
  504.         }
  505.         return $this;
  506.     }
  507.     /**
  508.      * @return Collection<int, Attendance>
  509.      */
  510.     public function getAttendances(): Collection
  511.     {
  512.         return $this->attendances;
  513.     }
  514.     public function addAttendance(Attendance $attendance): self
  515.     {
  516.         if (!$this->attendances->contains($attendance)) {
  517.             $this->attendances->add($attendance);
  518.             $attendance->setStudent($this);
  519.         }
  520.         return $this;
  521.     }
  522.     public function removeAttendance(Attendance $attendance): self
  523.     {
  524.         if ($this->attendances->removeElement($attendance)) {
  525.             // set the owning side to null (unless already changed)
  526.             if ($attendance->getStudent() === $this) {
  527.                 $attendance->setStudent(null);
  528.             }
  529.         }
  530.         return $this;
  531.     }
  532.     /**
  533.      * Vérifie si l'élève est en ordre de paiement
  534.      */
  535.     public function isPaymentInOrder(): bool
  536.     {
  537.         foreach ($this->payments as $payment) {
  538.             $fee $payment->getFee();
  539.             if ($fee && !$fee->isFullyPaid()) {
  540.                 return false;
  541.             }
  542.         }
  543.         return true;
  544.     }
  545.     /**
  546.      * Calcule le montant total dû par l'élève
  547.      */
  548.     public function getTotalAmountDue(): float
  549.     {
  550.         $total 0;
  551.         foreach ($this->payments as $payment) {
  552.             $fee $payment->getFee();
  553.             if ($fee) {
  554.                 $total += $fee->getRemainingAmount();
  555.             }
  556.         }
  557.         return $total;
  558.     }
  559.     /**
  560.      * Calcule le montant total payé par l'élève
  561.      */
  562.     public function getTotalAmountPaid(): float
  563.     {
  564.         $total 0;
  565.         foreach ($this->payments as $payment) {
  566.             $total += (float) $payment->getAmountPaid();
  567.         }
  568.         return $total;
  569.     }
  570.     /**
  571.      * Récupère les frais impayés de l'élève
  572.      */
  573.     public function getUnpaidFees(): array
  574.     {
  575.         $unpaidFees = [];
  576.         foreach ($this->payments as $payment) {
  577.             $fee $payment->getFee();
  578.             if ($fee && !$fee->isFullyPaid()) {
  579.                 $unpaidFees[] = $fee;
  580.             }
  581.         }
  582.         return $unpaidFees;
  583.     }
  584. }