src/Entity/Person.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PersonRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=PersonRepository::class)
  7.  */
  8. class Person
  9. {
  10.     const PERSON_FIELD_NAME 'person_name';
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=255)
  19.      */
  20.     private $firstName;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $lastName;
  25.     /**
  26.      * @ORM\OneToOne(targetEntity=Student::class, inversedBy="person", cascade={"persist", "remove"})
  27.      */
  28.     private $student;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=City::class)
  31.      */
  32.     private $city;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $phone;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $email;
  41.     /**
  42.      * @ORM\OneToOne(targetEntity=Image::class, cascade={"persist", "remove"})
  43.      */
  44.     private $image;
  45.     /**
  46.      * @ORM\Column(type="text", nullable=true)
  47.      */
  48.     private $comment;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      */
  52.     private $lastName2;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=true)
  55.      */
  56.     private $telegramUserId;
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getFirstName(): ?string
  62.     {
  63.         return $this->firstName;
  64.     }
  65.     public function setFirstName(string $firstName): self
  66.     {
  67.         $this->firstName $firstName;
  68.         return $this;
  69.     }
  70.     public function getLastName(): ?string
  71.     {
  72.         return $this->lastName;
  73.     }
  74.     public function setLastName(string $lastName): self
  75.     {
  76.         $this->lastName $lastName;
  77.         return $this;
  78.     }
  79.     public function getStudent(): ?Student
  80.     {
  81.         return $this->student;
  82.     }
  83.     public function setStudent(?Student $student): self
  84.     {
  85.         $this->student $student;
  86.         return $this;
  87.     }
  88.     public function getName(array $options null): string
  89.     {
  90.         $options array_merge(
  91.             [
  92.                 "lastNameFirst" => false
  93.             ], ($options ?? [])
  94.         );
  95.         $name = ($options["lastNameFirst"] ? $this->getLastFirstName() : $this->firstName ' ' $this->lastName );
  96.         return $name;
  97.     }
  98.     public function getLastFirstName(): string
  99.     {
  100.         return $this->lastName ' ' $this->firstName;
  101.     }
  102.     public function getLastName2FirstName(): string
  103.     {
  104.         return $this->lastName2 ' ' $this->firstName;
  105.     }
  106.     public function getNameAndCityText(): string
  107.     {
  108.         return $this->getName() . " (" .
  109.             ($this->getCity() && trim($this->getCity()->getName()) ? $this->getCity()->getName() : "город не указан")
  110.             . ")";
  111.     }
  112.     public function getCityText(): string
  113.     {
  114.         return $this->getCity() ? $this->getCity()->getName() : "город не указан";
  115.     }
  116.     public function getCity(): ?City
  117.     {
  118.         return $this->city;
  119.     }
  120.     public function setCity(?City $city): self
  121.     {
  122.         $this->city $city;
  123.         return $this;
  124.     }
  125.     public function getPhone(): ?string
  126.     {
  127.         return $this->phone;
  128.     }
  129.     public function setPhone(?string $phone): self
  130.     {
  131.         $this->phone $phone;
  132.         return $this;
  133.     }
  134.     public function getEmail(): ?string
  135.     {
  136.         return $this->email;
  137.     }
  138.     public function setEmail(?string $email): self
  139.     {
  140.         $this->email $email;
  141.         return $this;
  142.     }
  143.     public function getImage(): ?Image
  144.     {
  145.         return $this->image;
  146.     }
  147.     public function setImage(?Image $image): self
  148.     {
  149.         $this->image $image;
  150.         return $this;
  151.     }
  152.     public function getComment(): ?string
  153.     {
  154.         return $this->comment;
  155.     }
  156.     public function setComment(?string $comment): self
  157.     {
  158.         $this->comment $comment;
  159.         return $this;
  160.     }
  161.     public function getLastName2(): ?string
  162.     {
  163.         return $this->lastName2;
  164.     }
  165.     public function setLastName2(?string $lastName2): self
  166.     {
  167.         $this->lastName2 $lastName2;
  168.         return $this;
  169.     }
  170.     public function getTelegramUserId(): ?string
  171.     {
  172.         return $this->telegramUserId;
  173.     }
  174.     public function setTelegramUserId(?string $telegramUserId): self
  175.     {
  176.         $this->telegramUserId $telegramUserId;
  177.         return $this;
  178.     }
  179. }