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