User.php 897B

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