vendor/roothirsch/core-bundle/Entity/ContactPerson.php line 19

Open in your IDE?
  1. <?php
  2. namespace Roothirsch\CoreBundle\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Dkd\Populate\PopulateTrait;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Roothirsch\CoreBundle\Entity\User;
  11. /**
  12. * @ORM\Entity(repositoryClass="Roothirsch\CoreBundle\Repository\ContactPersonRepository")
  13. * @ORM\Table(name="company_person")
  14. * @ApiResource
  15. */
  16. class ContactPerson
  17. {
  18. /**
  19. * @ORM\Id
  20. * @ORM\GeneratedValue
  21. * @ORM\Column(type="integer")
  22. * @Groups({"read", "write", "list"})
  23. */
  24. private $id;
  25. /**
  26. * @var \DateTime
  27. *
  28. * @Gedmo\Timestampable(on="create")
  29. * @ORM\Column(type="integer")
  30. * @Groups({"read", "write"})
  31. */
  32. private $created;
  33. /**
  34. * @var \DateTime
  35. *
  36. * @Gedmo\Timestampable(on="update")
  37. * @ORM\Column(type="integer")
  38. * @Groups({"read", "write"})
  39. */
  40. private $updated;
  41. /**
  42. * @ORM\Column(type="string")
  43. * @Assert\NotBlank()
  44. * @Assert\Email(message="email")
  45. * @Groups({"read", "write", "list"})
  46. */
  47. private $email;
  48. /**
  49. * @ORM\Column(type="string", nullable=true)
  50. * @Assert\NotBlank(message="blank")
  51. * @Groups({"read", "write", "list"})
  52. */
  53. private $firstName;
  54. /**
  55. * @ORM\Column(type="string", nullable=true)
  56. * @Assert\NotBlank(message="blank")
  57. * @Groups({"read", "write", "list"})
  58. */
  59. private $lastName;
  60. /**
  61. * @ORM\Column(type="string", nullable=true)
  62. * @Assert\NotBlank(message="blank")
  63. * @Groups({"read", "write", "list"})
  64. */
  65. private $area;
  66. /**
  67. * @ORM\Column(type="string", nullable=true)
  68. * @Assert\NotBlank(message="blank")
  69. * @Groups({"read", "write", "list"})
  70. */
  71. private $phone;
  72. /**
  73. * @ORM\Column(type="string", nullable=true)
  74. * @Assert\NotBlank(message="Dies ist ein Pflichtfeld")
  75. * @Groups({"read", "write", "list"})
  76. */
  77. private $image;
  78. /**
  79. * @var User[]
  80. * @ORM\OneToMany(targetEntity="User", mappedBy="contact")
  81. */
  82. private $users;
  83. public function __toString()
  84. {
  85. return $this->getFullName();
  86. }
  87. public function getFullName()
  88. {
  89. return $this->getFirstName() . ' ' . $this->getLastName();
  90. }
  91. /**
  92. * @return mixed
  93. */
  94. public function getId()
  95. {
  96. return $this->id;
  97. }
  98. /**
  99. * @param mixed $id
  100. */
  101. public function setId($id)
  102. {
  103. $this->id = $id;
  104. }
  105. /**
  106. * @return \DateTime
  107. */
  108. public function getCreated()
  109. {
  110. return $this->created;
  111. }
  112. /**
  113. * @param \DateTime $created
  114. */
  115. public function setCreated($created)
  116. {
  117. $this->created = $created;
  118. }
  119. /**
  120. * @return \DateTime
  121. */
  122. public function getUpdated()
  123. {
  124. return $this->updated;
  125. }
  126. /**
  127. * @param \DateTime $updated
  128. */
  129. public function setUpdated($updated)
  130. {
  131. $this->updated = $updated;
  132. }
  133. /**
  134. * @return mixed
  135. */
  136. public function getEmail()
  137. {
  138. return $this->email;
  139. }
  140. /**
  141. * @param mixed $email
  142. */
  143. public function setEmail($email)
  144. {
  145. $this->email = $email;
  146. }
  147. /**
  148. * @return mixed
  149. */
  150. public function getFirstName()
  151. {
  152. return $this->firstName;
  153. }
  154. /**
  155. * @param mixed $firstName
  156. */
  157. public function setFirstName($firstName)
  158. {
  159. $this->firstName = $firstName;
  160. }
  161. /**
  162. * @return mixed
  163. */
  164. public function getLastName()
  165. {
  166. return $this->lastName;
  167. }
  168. /**
  169. * @param mixed $lastName
  170. */
  171. public function setLastName($lastName)
  172. {
  173. $this->lastName = $lastName;
  174. }
  175. /**
  176. * @return mixed
  177. */
  178. public function getArea()
  179. {
  180. return $this->area;
  181. }
  182. /**
  183. * @param mixed $area
  184. */
  185. public function setArea($area)
  186. {
  187. $this->area = $area;
  188. }
  189. /**
  190. * @return mixed
  191. */
  192. public function getPhone()
  193. {
  194. return $this->phone;
  195. }
  196. /**
  197. * @param mixed $phone
  198. */
  199. public function setPhone($phone)
  200. {
  201. $this->phone = $phone;
  202. }
  203. /**
  204. * @return mixed
  205. */
  206. public function getImage()
  207. {
  208. return $this->image;
  209. }
  210. /**
  211. * @param mixed $image
  212. */
  213. public function setImage($image)
  214. {
  215. $this->image = $image;
  216. }
  217. /**
  218. * @return Collection|User[]
  219. */
  220. public function getUsers()
  221. {
  222. return $this->users;
  223. }
  224. public function addUser(User $user): self
  225. {
  226. if (!$this->users->contains($user)) {
  227. $user->setContact($this);
  228. $this->users[] = $user;
  229. }
  230. return $this;
  231. }
  232. public function removeUser(User $user): self
  233. {
  234. $user->setContact(null);
  235. $this->users->removeElement($user);
  236. return $this;
  237. }
  238. public function __construct()
  239. {
  240. $this->users = new \Doctrine\Common\Collections\ArrayCollection();
  241. }
  242. }