src/Entity/Student.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\Student\Status;
  4. use App\Repository\StudentRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=StudentRepository::class)
  10.  */
  11. class Student
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="smallint", nullable=true)
  21.      */
  22.     private $level null;
  23.     /**
  24.      * @ORM\OneToOne(targetEntity=Person::class, mappedBy="student")
  25.      */
  26.     private $person;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=StudentLevel::class, mappedBy="student")
  29.      */
  30.     private $levels;
  31.     /**
  32.      * @ORM\Column(type="enum", options={"values"="student_enum", "default"="active"})
  33.      */
  34.     private $status Status::STATUS_STUDENT_ACTIVE;
  35.     private ?string $studentLevelChangeComment null;
  36.     private ?CalendarEvent $studentLevelCalendarEvent null;
  37.     /**
  38.      * @ORM\Column(type="datetime")
  39.      */
  40.     private $createdAt;
  41.     /**
  42.      * @ORM\Column(type="boolean", nullable=true)
  43.      */
  44.     private $candidateReviewIsNotRequired;
  45.     /**
  46.      * @ORM\Column(type="boolean", nullable=true)
  47.      */
  48.     private $freeCalendarEventsAccess;
  49.     public function __construct()
  50.     {
  51.         $this->levels = new ArrayCollection();
  52.         $this->createdAt = new \DateTime();
  53.     }
  54.     public function getLevelText(): string
  55.     {
  56.         if ($this->getLevel() < || $this->getLevel() === null) {
  57.             return "нет уровня";
  58.         }
  59.         if ($this->getLevel() === 0) {
  60.             return "баз. ур.";
  61.         }
  62.         return (string)$this->getLevel() . " ур.";
  63.     }
  64.     public function getShortInfo(array $options null): string
  65.     {
  66.         return $this->getPerson()->getName($options) . (" (" $this->getLevelText() . ")");
  67.     }
  68.     public function getNameLevelCityText(): string
  69.     {
  70.         $person $this->getPerson();
  71.         return $person->getName() . " (" $this->getLevelText() . ", " .$person->getCityText() . ")";
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getLevel(): ?int
  78.     {
  79.         if (!Status::isAnyStudentStatus($this->getStatus())) {
  80.             return null;
  81.         }
  82.         return $this->level;
  83.     }
  84.     public function setLevel(?int $level): self
  85.     {
  86.         $this->level $level;
  87.         return $this;
  88.     }
  89.     public function getPerson(): ?Person
  90.     {
  91.         return $this->person;
  92.     }
  93.     public function setPerson(?Person $person): self
  94.     {
  95.         // unset the owning side of the relation if necessary
  96.         if ($person === null && $this->person !== null) {
  97.             $this->person->setStudent(null);
  98.         }
  99.         // set the owning side of the relation if necessary
  100.         if ($person !== null && $person->getStudent() !== $this) {
  101.             $person->setStudent($this);
  102.         }
  103.         $this->person $person;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection<int, StudentLevel>
  108.      */
  109.     public function getLevels(): Collection
  110.     {
  111.         return $this->levels;
  112.     }
  113.     public function addLevel(StudentLevel $level): self
  114.     {
  115.         if (!$this->levels->contains($level)) {
  116.             $this->levels[] = $level;
  117.             $level->setStudent($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removeLevel(StudentLevel $level): self
  122.     {
  123.         if ($this->levels->removeElement($level)) {
  124.             // set the owning side to null (unless already changed)
  125.             if ($level->getStudent() === $this) {
  126.                 $level->setStudent(null);
  127.             }
  128.         }
  129.         return $this;
  130.     }
  131.     public function getStatus()
  132.     {
  133.         return $this->status;
  134.     }
  135.     public function setStatus($status): self
  136.     {
  137.         $this->status $status;
  138.         return $this;
  139.     }
  140.     public function getStatusText(): ?string
  141.     {
  142.         return Status::getText($this->getStatus());
  143.     }
  144.     public function getStatusCssClass($prefix null): ?string
  145.     {
  146.         return Status::getCssClass($this->getStatus(), $prefix);
  147.     }
  148.     public function getCreatedAt(): ?\DateTimeInterface
  149.     {
  150.         return $this->createdAt;
  151.     }
  152.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  153.     {
  154.         $this->createdAt $createdAt;
  155.         return $this;
  156.     }
  157.     public function isCandidateReviewIsNotRequired(): ?bool
  158.     {
  159.         return $this->candidateReviewIsNotRequired;
  160.     }
  161.     public function setCandidateReviewIsNotRequired(?bool $candidateReviewIsNotRequired): self
  162.     {
  163.         $this->candidateReviewIsNotRequired $candidateReviewIsNotRequired;
  164.         return $this;
  165.     }
  166.     public function isFreeCalendarEventsAccess(): ?bool
  167.     {
  168.         return $this->freeCalendarEventsAccess;
  169.     }
  170.     public function setFreeCalendarEventsAccess(?bool $freeCalendarEventsAccess): self
  171.     {
  172.         $this->freeCalendarEventsAccess $freeCalendarEventsAccess;
  173.         return $this;
  174.     }
  175.     public function getStudentLevelChangeComment(): ?string
  176.     {
  177.         return $this->studentLevelChangeComment;
  178.     }
  179.     public function setStudentLevelChangeComment(?string $studentLevelChangeComment): self
  180.     {
  181.         $this->studentLevelChangeComment $studentLevelChangeComment;
  182.         return $this;
  183.     }
  184.     public function getStudentLevelCalendarEvent(): ?CalendarEvent
  185.     {
  186.         return $this->studentLevelCalendarEvent;
  187.     }
  188.     public function setStudentLevelCalendarEvent(?CalendarEvent $studentLevelCalendarEvent): self
  189.     {
  190.         $this->studentLevelCalendarEvent $studentLevelCalendarEvent;
  191.         return $this;
  192.     }
  193. }