src/Entity/Student.php line 16

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;
  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.     /**
  37.      * @ORM\Column(type="datetime")
  38.      */
  39.     private $createdAt;
  40.     /**
  41.      * @ORM\Column(type="boolean", nullable=true)
  42.      */
  43.     private $candidateReviewIsNotRequired;
  44.     /**
  45.      * @ORM\Column(type="boolean", nullable=true)
  46.      */
  47.     private $freeCalendarEventsAccess;
  48.     public function __construct()
  49.     {
  50.         $this->levels = new ArrayCollection();
  51.         $this->createdAt = new \DateTime();
  52.     }
  53.     public function getLevelText(): string
  54.     {
  55.         if ($this->getLevel() < || $this->getLevel() === null) {
  56.             return "нет уровня";
  57.         }
  58.         if ($this->getLevel() === 0) {
  59.             return "баз. ур.";
  60.         }
  61.         return (string)$this->getLevel() . " ур.";
  62.     }
  63.     public function getShortInfo(array $options null): string
  64.     {
  65.         return $this->getPerson()->getName($options) . (" (" $this->getLevelText() . ")");
  66.     }
  67.     public function getNameLevelCityText(): string
  68.     {
  69.         $person $this->getPerson();
  70.         return $person->getName() . " (" $this->getLevelText() . ", " .$person->getCityText() . ")";
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getLevel(): ?int
  77.     {
  78.         return $this->level;
  79.     }
  80.     public function setLevel(?int $level): self
  81.     {
  82.         $this->level $level;
  83.         return $this;
  84.     }
  85.     public function getPerson(): ?Person
  86.     {
  87.         return $this->person;
  88.     }
  89.     public function setPerson(?Person $person): self
  90.     {
  91.         // unset the owning side of the relation if necessary
  92.         if ($person === null && $this->person !== null) {
  93.             $this->person->setStudent(null);
  94.         }
  95.         // set the owning side of the relation if necessary
  96.         if ($person !== null && $person->getStudent() !== $this) {
  97.             $person->setStudent($this);
  98.         }
  99.         $this->person $person;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return Collection<int, StudentLevel>
  104.      */
  105.     public function getLevels(): Collection
  106.     {
  107.         return $this->levels;
  108.     }
  109.     public function addLevel(StudentLevel $level): self
  110.     {
  111.         if (!$this->levels->contains($level)) {
  112.             $this->levels[] = $level;
  113.             $level->setStudent($this);
  114.         }
  115.         return $this;
  116.     }
  117.     public function removeLevel(StudentLevel $level): self
  118.     {
  119.         if ($this->levels->removeElement($level)) {
  120.             // set the owning side to null (unless already changed)
  121.             if ($level->getStudent() === $this) {
  122.                 $level->setStudent(null);
  123.             }
  124.         }
  125.         return $this;
  126.     }
  127.     public function getStatus()
  128.     {
  129.         return $this->status;
  130.     }
  131.     public function setStatus($status): self
  132.     {
  133.         $this->status $status;
  134.         return $this;
  135.     }
  136.     public function getStatusText(): ?string
  137.     {
  138.         return Status::getText($this->getStatus());
  139.     }
  140.     public function getStatusCssClass($prefix null): ?string
  141.     {
  142.         return Status::getCssClass($this->getStatus(), $prefix);
  143.     }
  144.     public function getCreatedAt(): ?\DateTimeInterface
  145.     {
  146.         return $this->createdAt;
  147.     }
  148.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  149.     {
  150.         $this->createdAt $createdAt;
  151.         return $this;
  152.     }
  153.     public function isCandidateReviewIsNotRequired(): ?bool
  154.     {
  155.         return $this->candidateReviewIsNotRequired;
  156.     }
  157.     public function setCandidateReviewIsNotRequired(?bool $candidateReviewIsNotRequired): self
  158.     {
  159.         $this->candidateReviewIsNotRequired $candidateReviewIsNotRequired;
  160.         return $this;
  161.     }
  162.     public function isFreeCalendarEventsAccess(): ?bool
  163.     {
  164.         return $this->freeCalendarEventsAccess;
  165.     }
  166.     public function setFreeCalendarEventsAccess(?bool $freeCalendarEventsAccess): self
  167.     {
  168.         $this->freeCalendarEventsAccess $freeCalendarEventsAccess;
  169.         return $this;
  170.     }
  171.     public function getStudentLevelChangeComment(): ?string
  172.     {
  173.         return $this->studentLevelChangeComment;
  174.     }
  175.     public function setStudentLevelChangeComment(?string $studentLevelChangeComment): self
  176.     {
  177.         $this->studentLevelChangeComment $studentLevelChangeComment;
  178.         return $this;
  179.     }
  180. }