src/Entity/ContactableAddress.php line 24

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use MedBrief\MSR\Repository\ContactableAddressRepository;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9. * ContactableAddress
  10. *
  11. * @ORM\Table(name="ContactableAddress")
  12. *
  13. * @ORM\Entity(repositoryClass=ContactableAddressRepository::class)
  14. *
  15. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  16. *
  17. * @Audit\Auditable
  18. *
  19. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  20. */
  21. class ContactableAddress
  22. {
  23. /**
  24. * @var int
  25. *
  26. * @ORM\Column(name="id", type="integer")
  27. *
  28. * @ORM\Id
  29. *
  30. * @ORM\GeneratedValue(strategy="IDENTITY")
  31. */
  32. private $id;
  33. /**
  34. * @var \DateTime|null
  35. *
  36. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  37. */
  38. private $deletedAt;
  39. /**
  40. * @var string
  41. *
  42. * @ORM\Column(name="name", type="string")
  43. */
  44. private $name;
  45. /**
  46. * @var string
  47. */
  48. private $contact_full_name;
  49. /**
  50. * @var string
  51. */
  52. private $email;
  53. /**
  54. * @var string
  55. */
  56. private $phone;
  57. /**
  58. * @var string
  59. *
  60. * @Groups({"account:read", "matter_request:read"})
  61. *
  62. * @ORM\Column(name="contact_name", type="string", nullable=true)
  63. */
  64. private $contact_name;
  65. /**
  66. * @var string|null
  67. *
  68. * @ORM\Column(name="contact_email", type="string", nullable=true)
  69. */
  70. private $contact_email;
  71. /**
  72. * @Groups({"account:read", "matter_request:read"})
  73. *
  74. * @var string|null
  75. *
  76. * @ORM\Column(name="contact_phone", type="string", nullable=true)
  77. */
  78. private $contact_phone;
  79. /**
  80. * @Groups({"account:read", "matter_request:read"})
  81. *
  82. * @var string|null
  83. *
  84. * @ORM\Column(name="line1", type="string", nullable=true)
  85. */
  86. private $line1;
  87. /**
  88. * @Groups({"account:read", "matter_request:read"})
  89. *
  90. * @var string|null
  91. *
  92. * @ORM\Column(name="line2", type="string", nullable=true)
  93. */
  94. private $line2;
  95. /**
  96. * @Groups({"account:read", "matter_request:read"})
  97. *
  98. * @var string|null
  99. *
  100. * @ORM\Column(name="city", type="string", nullable=true)
  101. */
  102. private $city;
  103. /**
  104. * @Groups({"account:read", "matter_request:read"})
  105. *
  106. * @var string|null
  107. *
  108. * @ORM\Column(name="postal_code", type="string", nullable=true)
  109. */
  110. private $postal_code;
  111. /**
  112. * @var string
  113. *
  114. * @ORM\Column(name="country", type="string")
  115. */
  116. private $country;
  117. /**
  118. * @var string|null
  119. *
  120. * @ORM\Column(name="province", type="string", nullable=true)
  121. */
  122. private $province;
  123. /**
  124. * @var \DateTime
  125. *
  126. * @ORM\Column(name="created", type="datetime")
  127. *
  128. * @Gedmo\Timestampable(on="create")
  129. */
  130. private $created;
  131. /**
  132. * @var \DateTime
  133. *
  134. * @ORM\Column(name="updated", type="datetime")
  135. *
  136. * @Gedmo\Timestampable(on="update")
  137. */
  138. private $updated;
  139. /**
  140. * @var \Doctrine\Common\Collections\Collection
  141. *
  142. * @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\Account", mappedBy="offices")
  143. */
  144. private $accounts;
  145. /**
  146. * Constructor
  147. */
  148. public function __construct()
  149. {
  150. $this->accounts = new \Doctrine\Common\Collections\ArrayCollection();
  151. }
  152. public function __toString()
  153. {
  154. return $this->getName();
  155. }
  156. /**
  157. * Get id
  158. *
  159. * @return int
  160. */
  161. public function getId()
  162. {
  163. return $this->id;
  164. }
  165. /**
  166. * Set name
  167. *
  168. * @param string $name
  169. *
  170. * @return ContactableAddress
  171. */
  172. public function setName($name)
  173. {
  174. $this->name = $name;
  175. return $this;
  176. }
  177. /**
  178. * Get name
  179. *
  180. * @return string
  181. */
  182. public function getName()
  183. {
  184. return $this->name;
  185. }
  186. /**
  187. * Set contact_full_name
  188. *
  189. * @param string $contactFullName
  190. *
  191. * @return ContactableAddress
  192. */
  193. public function setContactFullName($contactFullName)
  194. {
  195. $this->contact_full_name = $contactFullName;
  196. return $this;
  197. }
  198. /**
  199. * Get contact_full_name
  200. *
  201. * @return string
  202. */
  203. public function getContactFullName()
  204. {
  205. return $this->contact_full_name;
  206. }
  207. /**
  208. * Set email
  209. *
  210. * @param string $email
  211. *
  212. * @return ContactableAddress
  213. */
  214. public function setEmail($email)
  215. {
  216. $this->email = $email;
  217. return $this;
  218. }
  219. /**
  220. * Get email
  221. *
  222. * @return string
  223. */
  224. public function getEmail()
  225. {
  226. return $this->email;
  227. }
  228. /**
  229. * Set phone
  230. *
  231. * @param string $phone
  232. *
  233. * @return ContactableAddress
  234. */
  235. public function setPhone($phone)
  236. {
  237. $this->phone = $phone;
  238. return $this;
  239. }
  240. /**
  241. * Get phone
  242. *
  243. * @return string
  244. */
  245. public function getPhone()
  246. {
  247. return $this->phone;
  248. }
  249. /**
  250. * Set line1
  251. *
  252. * @param string $line1
  253. *
  254. * @return ContactableAddress
  255. */
  256. public function setLine1($line1)
  257. {
  258. $this->line1 = $line1;
  259. return $this;
  260. }
  261. /**
  262. * Get line1
  263. *
  264. * @return string
  265. */
  266. public function getLine1()
  267. {
  268. return $this->line1;
  269. }
  270. /**
  271. * Set line2
  272. *
  273. * @param string $line2
  274. *
  275. * @return ContactableAddress
  276. */
  277. public function setLine2($line2)
  278. {
  279. $this->line2 = $line2;
  280. return $this;
  281. }
  282. /**
  283. * Get line2
  284. *
  285. * @return string
  286. */
  287. public function getLine2()
  288. {
  289. return $this->line2;
  290. }
  291. /**
  292. * Set city
  293. *
  294. * @param string $city
  295. *
  296. * @return ContactableAddress
  297. */
  298. public function setCity($city)
  299. {
  300. $this->city = $city;
  301. return $this;
  302. }
  303. /**
  304. * Get city
  305. *
  306. * @return string
  307. */
  308. public function getCity()
  309. {
  310. return $this->city;
  311. }
  312. /**
  313. * Set postal_code
  314. *
  315. * @param string $postalCode
  316. *
  317. * @return ContactableAddress
  318. */
  319. public function setPostalCode($postalCode)
  320. {
  321. $this->postal_code = $postalCode;
  322. return $this;
  323. }
  324. /**
  325. * Get postal_code
  326. *
  327. * @return string
  328. */
  329. public function getPostalCode()
  330. {
  331. return $this->postal_code;
  332. }
  333. /**
  334. * Set country
  335. *
  336. * @param string $country
  337. *
  338. * @return ContactableAddress
  339. */
  340. public function setCountry($country)
  341. {
  342. $this->country = $country;
  343. return $this;
  344. }
  345. /**
  346. * Get country
  347. *
  348. * @return string
  349. */
  350. public function getCountry()
  351. {
  352. return $this->country;
  353. }
  354. /**
  355. * Set created
  356. *
  357. * @param \DateTime $created
  358. *
  359. * @return ContactableAddress
  360. */
  361. public function setCreated($created)
  362. {
  363. $this->created = $created;
  364. return $this;
  365. }
  366. /**
  367. * Get created
  368. *
  369. * @return \DateTime
  370. */
  371. public function getCreated()
  372. {
  373. return $this->created;
  374. }
  375. /**
  376. * Set updated
  377. *
  378. * @param \DateTime $updated
  379. *
  380. * @return ContactableAddress
  381. */
  382. public function setUpdated($updated)
  383. {
  384. $this->updated = $updated;
  385. return $this;
  386. }
  387. /**
  388. * Get updated
  389. *
  390. * @return \DateTime
  391. */
  392. public function getUpdated()
  393. {
  394. return $this->updated;
  395. }
  396. /**
  397. * Set province
  398. *
  399. * @param string $province
  400. *
  401. * @return ContactableAddress
  402. */
  403. public function setProvince($province)
  404. {
  405. $this->province = $province;
  406. return $this;
  407. }
  408. /**
  409. * Get province
  410. *
  411. * @return string
  412. */
  413. public function getProvince()
  414. {
  415. return $this->province;
  416. }
  417. /**
  418. * Add accounts
  419. *
  420. * @param Account $accounts
  421. *
  422. * @return ContactableAddress
  423. */
  424. public function addAccount(Account $accounts)
  425. {
  426. $this->accounts[] = $accounts;
  427. return $this;
  428. }
  429. /**
  430. * Remove accounts
  431. *
  432. * @param Account $accounts
  433. */
  434. public function removeAccount(Account $accounts)
  435. {
  436. $this->accounts->removeElement($accounts);
  437. }
  438. /**
  439. * Get accounts
  440. *
  441. * @return \Doctrine\Common\Collections\Collection
  442. */
  443. public function getAccounts()
  444. {
  445. return $this->accounts;
  446. }
  447. /**
  448. * Set contact_name
  449. *
  450. * @param string $contactName
  451. *
  452. * @return ContactableAddress
  453. */
  454. public function setContactName($contactName)
  455. {
  456. $this->contact_name = $contactName;
  457. return $this;
  458. }
  459. /**
  460. * Get contact_name
  461. *
  462. * @return string
  463. */
  464. public function getContactName()
  465. {
  466. return $this->contact_name;
  467. }
  468. /**
  469. * Set contact_email
  470. *
  471. * @param string $contactEmail
  472. *
  473. * @return ContactableAddress
  474. */
  475. public function setContactEmail($contactEmail)
  476. {
  477. $this->contact_email = $contactEmail;
  478. return $this;
  479. }
  480. /**
  481. * Get contact_email
  482. *
  483. * @return string
  484. */
  485. public function getContactEmail()
  486. {
  487. return $this->contact_email;
  488. }
  489. /**
  490. * Set contact_phone
  491. *
  492. * @param string $contactPhone
  493. *
  494. * @return ContactableAddress
  495. */
  496. public function setContactPhone($contactPhone)
  497. {
  498. $this->contact_phone = $contactPhone;
  499. return $this;
  500. }
  501. /**
  502. * Get contact_phone
  503. *
  504. * @return string
  505. */
  506. public function getContactPhone()
  507. {
  508. return $this->contact_phone;
  509. }
  510. /**
  511. * Returns the formatted address
  512. *
  513. * @param bool $inline
  514. *
  515. * @return string
  516. */
  517. public function getFormatted(bool $inline = false): string
  518. {
  519. $separator = $inline ? ', ' : '<br>';
  520. $formattedStr
  521. = ($this->getLine1() ? $this->getLine1() . $separator : '')
  522. . ($this->getLine2() ? $this->getLine2() . $separator : '')
  523. . ($this->getCity() ? $this->getCity() . $separator : '')
  524. . ($this->getProvince() ? $this->getProvince() . $separator : '')
  525. . ($this->getCountry() ? $this->getCountry() . $separator : '')
  526. . ($this->getPostalCode() ? $this->getPostalCode() . $separator : '');
  527. return trim($formattedStr, $separator);
  528. }
  529. /**
  530. * Set deletedAt
  531. *
  532. * @param \DateTime $deletedAt
  533. *
  534. * @return ContactableAddress
  535. */
  536. public function setDeletedAt($deletedAt)
  537. {
  538. $this->deletedAt = $deletedAt;
  539. return $this;
  540. }
  541. /**
  542. * Get deletedAt
  543. *
  544. * @return \DateTime
  545. */
  546. public function getDeletedAt()
  547. {
  548. return $this->deletedAt;
  549. }
  550. }