<?php
namespace App\Entity;
use App\Repository\PersonRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=PersonRepository::class)
*/
class Person
{
const PERSON_FIELD_NAME = 'person_name';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $firstName;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastName;
/**
* @ORM\OneToOne(targetEntity=Student::class, inversedBy="person", cascade={"persist", "remove"})
*/
private $student;
/**
* @ORM\ManyToOne(targetEntity=City::class)
*/
private $city;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\OneToOne(targetEntity=Image::class, cascade={"persist", "remove"})
*/
private $image;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lastName2;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $telegramUserId;
public function getId(): ?int
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getStudent(): ?Student
{
return $this->student;
}
public function setStudent(?Student $student): self
{
$this->student = $student;
return $this;
}
public function getName(array $options = null): string
{
$options = array_merge(
[
"lastNameFirst" => false
], ($options ?? [])
);
$name = ($options["lastNameFirst"] ? $this->getLastFirstName() : $this->firstName . ' ' . $this->lastName );
return $name;
}
public function getLastFirstName(): string
{
return $this->lastName . ' ' . $this->firstName;
}
public function getLastName2FirstName(): string
{
return $this->lastName2 . ' ' . $this->firstName;
}
public function getNameAndCityText(): string
{
return $this->getName() . " (" .
($this->getCity() && trim($this->getCity()->getName()) ? $this->getCity()->getName() : "город не указан")
. ")";
}
public function getCityText(): string
{
return $this->getCity() ? $this->getCity()->getName() : "город не указан";
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getImage(): ?Image
{
return $this->image;
}
public function setImage(?Image $image): self
{
$this->image = $image;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getLastName2(): ?string
{
return $this->lastName2;
}
public function setLastName2(?string $lastName2): self
{
$this->lastName2 = $lastName2;
return $this;
}
public function getTelegramUserId(): ?string
{
return $this->telegramUserId;
}
public function setTelegramUserId(?string $telegramUserId): self
{
$this->telegramUserId = $telegramUserId;
return $this;
}
}