<?php
namespace App\Entity;
use App\Enum\Student\Status;
use App\Repository\StudentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=StudentRepository::class)
*/
class Student
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="smallint")
*/
private $level = 0;
/**
* @ORM\OneToOne(targetEntity=Person::class, mappedBy="student", cascade={"persist", "remove"})
*/
private $person;
/**
* @ORM\OneToMany(targetEntity=StudentLevel::class, mappedBy="student")
*/
private $levels;
/**
* @ORM\Column(type="enum", options={"values"="student_enum", "default"="active"})
*/
private $status = Status::STATUS_ACTIVE;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $candidateReviewIsNotRequired;
public function __construct()
{
$this->levels = new ArrayCollection();
$this->createdAt = new \DateTime();
}
public function getLevelText(): string
{
if ($this->getLevel() === 0) {
return "базовый ур.";
}
return (string)$this->getLevel() . " ур.";
}
public function getShortInfo(array $options = null): string
{
return $this->getPerson()->getName($options) . (" (" . $this->getLevelText() . ")");
}
public function getNameLevelCityText(): string
{
$person = $this->getPerson();
return $person->getName() . " (" . $this->getLevelText() . ", " .$person->getCityText() . ")";
}
public function getId(): ?int
{
return $this->id;
}
public function getLevel(): ?int
{
return $this->level;
}
public function setLevel(int $level): self
{
$this->level = $level;
return $this;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function setPerson(?Person $person): self
{
// unset the owning side of the relation if necessary
if ($person === null && $this->person !== null) {
$this->person->setStudent(null);
}
// set the owning side of the relation if necessary
if ($person !== null && $person->getStudent() !== $this) {
$person->setStudent($this);
}
$this->person = $person;
return $this;
}
/**
* @return Collection<int, StudentLevel>
*/
public function getLevels(): Collection
{
return $this->levels;
}
public function addLevel(StudentLevel $level): self
{
if (!$this->levels->contains($level)) {
$this->levels[] = $level;
$level->setStudent($this);
}
return $this;
}
public function removeLevel(StudentLevel $level): self
{
if ($this->levels->removeElement($level)) {
// set the owning side to null (unless already changed)
if ($level->getStudent() === $this) {
$level->setStudent(null);
}
}
return $this;
}
public function getStatus()
{
return $this->status;
}
public function setStatus($status): self
{
$this->status = $status;
return $this;
}
public function getStatusText(): ?string
{
return Status::getText($this->getStatus());
}
public function getStatusCssClass($prefix = null): ?string
{
return Status::getCssClass($this->getStatus(), $prefix);
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function isCandidateReviewIsNotRequired(): ?bool
{
return $this->candidateReviewIsNotRequired;
}
public function setCandidateReviewIsNotRequired(?bool $candidateReviewIsNotRequired): self
{
$this->candidateReviewIsNotRequired = $candidateReviewIsNotRequired;
return $this;
}
}