src/Entity/Person.php line 23

Open in your IDE?
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: parcel
  5. * Date: 9/20/18
  6. * Time: 4:01 PM
  7. */
  8. namespace App\Entity;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use JMS\Serializer\Annotation as Serializer;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. /**
  13. *
  14. * @ORM\Entity
  15. * @ORM\Table(name="person", uniqueConstraints={
  16. * @ORM\UniqueConstraint(name="national_id", columns={"national_id"}),
  17. * @ORM\UniqueConstraint(name="phone_number", columns={"phone_number"}) } )
  18. */
  19. class Person {
  20. //@UniqueEntity(fields={"phoneNumber"}, errorPath="phoneNumber", message="A Person with this Phone Number Exists")
  21. // * @UniqueEntity(fields={"nationalId"}, errorPath="nationalId", message="This person exists")
  22. /**
  23. * @ORM\Id
  24. * @ORM\GeneratedValue(strategy="IDENTITY")
  25. * @ORM\Column(type="integer")
  26. */
  27. private $id;
  28. /**
  29. * @ORM\Column(type="string", length=45)
  30. */
  31. private $firstName;
  32. /**
  33. * @ORM\Column(type="string", length=45)
  34. */
  35. private $secondName;
  36. /**
  37. * @ORM\Column(type="string", length=45)
  38. */
  39. private $sirName;
  40. /**
  41. * @ORM\Column(type="string", length=6)
  42. */
  43. private $gender;
  44. /**
  45. * @ORM\Column(type="integer", length=8, unique=true)
  46. */
  47. private $nationalId;
  48. /**
  49. * @ORM\Column(type="string", length=12, unique=true)
  50. */
  51. private $phoneNumber;
  52. /**
  53. * @ORM\Column(type="datetime")
  54. */
  55. private $createdAt;
  56. /**
  57. * @ORM\Column(type="date")
  58. */
  59. private $dateOfBirth;
  60. /**
  61. * @ORM\Column(type="string")
  62. */
  63. private $preferredName;
  64. /**
  65. * @var \App\Entity\User
  66. * @Serializer\Type("App\Entity\User")
  67. * @ORM\ManyToOne(targetEntity="App\Entity\User")
  68. * @ORM\JoinColumns({
  69. * @ORM\JoinColumn(name="created_by", referencedColumnName="id")
  70. * })
  71. */
  72. private $createdBy;
  73. /**
  74. * @return mixed
  75. */
  76. public function getId()
  77. {
  78. return $this->id;
  79. }
  80. /**
  81. * @param mixed $id
  82. */
  83. public function setId($id)
  84. {
  85. $this->id = $id;
  86. }
  87. /**
  88. * @return mixed
  89. */
  90. public function getFirstName()
  91. {
  92. return $this->firstName;
  93. }
  94. /**
  95. * @param mixed $firstName
  96. */
  97. public function setFirstName($firstName)
  98. {
  99. $this->firstName = $firstName;
  100. }
  101. /**
  102. * @return mixed
  103. */
  104. public function getSecondName()
  105. {
  106. return $this->secondName;
  107. }
  108. /**
  109. * @param mixed $secondName
  110. */
  111. public function setSecondName($secondName)
  112. {
  113. $this->secondName = $secondName;
  114. }
  115. /**
  116. * @return mixed
  117. */
  118. public function getSirName()
  119. {
  120. return $this->sirName;
  121. }
  122. /**
  123. * @param mixed $sirName
  124. */
  125. public function setSirName($sirName)
  126. {
  127. $this->sirName = $sirName;
  128. }
  129. /**
  130. * @return mixed
  131. */
  132. public function getGender()
  133. {
  134. return $this->gender;
  135. }
  136. /**
  137. * @param mixed $gender
  138. */
  139. public function setGender($gender)
  140. {
  141. $this->gender = $gender;
  142. }
  143. /**
  144. * @return mixed
  145. */
  146. public function getPhoneNumber()
  147. {
  148. return $this->phoneNumber;
  149. }
  150. /**
  151. * @param mixed $phoneNumber
  152. */
  153. public function setPhoneNumber($phoneNumber)
  154. {
  155. $this->phoneNumber = $phoneNumber;
  156. }
  157. /**
  158. * @return mixed
  159. */
  160. public function getNationalId()
  161. {
  162. return $this->nationalId;
  163. }
  164. /**
  165. * @param mixed $nationalId
  166. */
  167. public function setNationalId($nationalId)
  168. {
  169. $this->nationalId = $nationalId;
  170. }
  171. /**
  172. * @return mixed
  173. */
  174. public function getCreatedAt()
  175. {
  176. return $this->createdAt;
  177. }
  178. /**
  179. * @param mixed $createdAt
  180. */
  181. public function setCreatedAt($createdAt)
  182. {
  183. $this->createdAt = $createdAt;
  184. }
  185. /**
  186. * @return User
  187. */
  188. public function getCreatedBy()
  189. {
  190. return $this->createdBy;
  191. }
  192. /**
  193. * @param User $createdBy
  194. */
  195. public function setCreatedBy($createdBy)
  196. {
  197. $this->createdBy = $createdBy;
  198. }
  199. /**
  200. * @return mixed
  201. */
  202. public function getDateOfBirth()
  203. {
  204. return $this->dateOfBirth;
  205. }
  206. /**
  207. * @param mixed $dateOfBirth
  208. */
  209. public function setDateOfBirth($dateOfBirth)
  210. {
  211. $this->dateOfBirth = $dateOfBirth;
  212. }
  213. /**
  214. * @return mixed
  215. */
  216. public function getPreferredName()
  217. {
  218. return $this->preferredName;
  219. }
  220. /**
  221. * @param mixed $preferredName
  222. */
  223. public function setPreferredName($preferredName): void
  224. {
  225. $this->preferredName = $preferredName;
  226. }
  227. public function __toString() {
  228. // TODO: Implement __toString() method.
  229. return $this->firstName.' '.$this->secondName.' '.$this->sirName;
  230. }
  231. }