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