<?php 
/** 
 * Created by PhpStorm. 
 * User: parcel 
 * Date: 9/20/18 
 * Time: 4:01 PM 
 */ 
 
namespace App\Entity; 
 
 
use Doctrine\ORM\Mapping as ORM; 
use JMS\Serializer\Annotation as Serializer; 
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 
 
/** 
 * 
 * @ORM\Entity 
 * @ORM\Table(name="person", uniqueConstraints={ 
 *     @ORM\UniqueConstraint(name="national_id", columns={"national_id"}), 
 * @ORM\UniqueConstraint(name="phone_number", columns={"phone_number"}) } ) 
 */ 
class Person { 
 
//@UniqueEntity(fields={"phoneNumber"}, errorPath="phoneNumber", message="A Person with this Phone Number Exists") 
// * @UniqueEntity(fields={"nationalId"}, errorPath="nationalId", message="This person exists") 
 
    /** 
     * @ORM\Id 
     * @ORM\GeneratedValue(strategy="IDENTITY") 
     * @ORM\Column(type="integer") 
     */ 
    private $id; 
 
    /** 
     * @ORM\Column(type="string", length=45) 
     */ 
    private $firstName; 
 
    /** 
     * @ORM\Column(type="string", length=45) 
     */ 
    private $secondName; 
 
    /** 
     * @ORM\Column(type="string", length=45) 
     */ 
    private $sirName; 
 
    /** 
     * @ORM\Column(type="string", length=6) 
     */ 
    private $gender; 
 
    /** 
     * @ORM\Column(type="integer", length=8, unique=true) 
     */ 
    private $nationalId; 
 
 
    /** 
     * @ORM\Column(type="string", length=12, unique=true) 
     */ 
    private $phoneNumber; 
 
 
 
    /** 
     * @ORM\Column(type="datetime") 
     */ 
    private $createdAt; 
 
 
    /** 
     * @ORM\Column(type="date") 
     */ 
    private $dateOfBirth; 
 
 
    /** 
     * @ORM\Column(type="string") 
     */ 
    private $preferredName; 
 
 
    /** 
     * @var \App\Entity\User 
     * @Serializer\Type("App\Entity\User") 
     * @ORM\ManyToOne(targetEntity="App\Entity\User") 
     * @ORM\JoinColumns({ 
     *   @ORM\JoinColumn(name="created_by", referencedColumnName="id") 
     * }) 
     */ 
    private $createdBy; 
 
    /** 
     * @return mixed 
     */ 
    public function getId() 
    { 
        return $this->id; 
    } 
 
    /** 
     * @param mixed $id 
     */ 
    public function setId($id) 
    { 
        $this->id = $id; 
    } 
 
    /** 
     * @return mixed 
     */ 
    public function getFirstName() 
    { 
        return $this->firstName; 
    } 
 
    /** 
     * @param mixed $firstName 
     */ 
    public function setFirstName($firstName) 
    { 
        $this->firstName = $firstName; 
    } 
 
    /** 
     * @return mixed 
     */ 
    public function getSecondName() 
    { 
        return $this->secondName; 
    } 
 
    /** 
     * @param mixed $secondName 
     */ 
    public function setSecondName($secondName) 
    { 
        $this->secondName = $secondName; 
    } 
 
    /** 
     * @return mixed 
     */ 
    public function getSirName() 
    { 
        return $this->sirName; 
    } 
 
    /** 
     * @param mixed $sirName 
     */ 
    public function setSirName($sirName) 
    { 
        $this->sirName = $sirName; 
    } 
 
    /** 
     * @return mixed 
     */ 
    public function getGender() 
    { 
        return $this->gender; 
    } 
 
    /** 
     * @param mixed $gender 
     */ 
    public function setGender($gender) 
    { 
        $this->gender = $gender; 
    } 
 
    /** 
     * @return mixed 
     */ 
    public function getPhoneNumber() 
    { 
        return $this->phoneNumber; 
    } 
 
    /** 
     * @param mixed $phoneNumber 
     */ 
    public function setPhoneNumber($phoneNumber) 
    { 
        $this->phoneNumber = $phoneNumber; 
    } 
 
 
    /** 
     * @return mixed 
     */ 
    public function getNationalId() 
    { 
        return $this->nationalId; 
    } 
 
    /** 
     * @param mixed $nationalId 
     */ 
    public function setNationalId($nationalId) 
    { 
        $this->nationalId = $nationalId; 
    } 
 
 
 
    /** 
     * @return mixed 
     */ 
    public function getCreatedAt() 
    { 
        return $this->createdAt; 
    } 
 
    /** 
     * @param mixed $createdAt 
     */ 
    public function setCreatedAt($createdAt) 
    { 
        $this->createdAt = $createdAt; 
    } 
 
    /** 
     * @return User 
     */ 
    public function getCreatedBy() 
    { 
        return $this->createdBy; 
    } 
 
    /** 
     * @param User $createdBy 
     */ 
    public function setCreatedBy($createdBy) 
    { 
        $this->createdBy = $createdBy; 
    } 
 
    /** 
     * @return mixed 
     */ 
    public function getDateOfBirth() 
    { 
        return $this->dateOfBirth; 
    } 
 
    /** 
     * @param mixed $dateOfBirth 
     */ 
    public function setDateOfBirth($dateOfBirth) 
    { 
        $this->dateOfBirth = $dateOfBirth; 
    } 
 
    /** 
     * @return mixed 
     */ 
    public function getPreferredName() 
    { 
        return $this->preferredName; 
    } 
 
    /** 
     * @param mixed $preferredName 
     */ 
    public function setPreferredName($preferredName): void 
    { 
        $this->preferredName = $preferredName; 
    } 
 
 
 
    public function __toString() { 
        // TODO: Implement __toString() method. 
        return $this->firstName.' '.$this->secondName.' '.$this->sirName; 
    } 
 
}