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