Address.php 810B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Entities;
  3. /** @Entity @Table(name="addresses") */
  4. class Address
  5. {
  6. /**
  7. * @Id @Column(type="integer")
  8. * @GeneratedValue(strategy="AUTO")
  9. */
  10. private $id;
  11. /** @Column(type="string", length=255) */
  12. private $street;
  13. /** @OneToOne(targetEntity="User", mappedBy="address") */
  14. private $user;
  15. public function getId()
  16. {
  17. return $this->id;
  18. }
  19. public function getStreet()
  20. {
  21. return $this->street;
  22. }
  23. public function setStreet($street)
  24. {
  25. $this->street = $street;
  26. }
  27. public function getUser()
  28. {
  29. return $this->user;
  30. }
  31. public function setUser(User $user)
  32. {
  33. if ($this->user !== $user) {
  34. $this->user = $user;
  35. $user->setAddress($this);
  36. }
  37. }
  38. }