src/ECommerceBundle/Entity/CartGuestData.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\ECommerceBundle\Entity;
  3. use App\NewShippingBundle\Entity\Zone;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7. * @ORM\Table("cart_guest_data")
  8. * @ORM\Entity()
  9. */
  10. class CartGuestData
  11. {
  12. /**
  13. * @Assert\NotBlank()
  14. * @ORM\Id
  15. * @ORM\OneToOne(targetEntity="Cart", inversedBy="cartGuestData")
  16. * @ORM\JoinColumn(name="cart_id", referencedColumnName="id", onDelete="CASCADE")
  17. */
  18. private ?Cart $cart = null;
  19. /**
  20. * @ORM\Column(name="name", type="string", length=100)
  21. */
  22. private ?string $name = null;
  23. /**
  24. * @ORM\Column(name="email", type="string", length=255)
  25. */
  26. private ?string $email = null;
  27. /**
  28. * @ORM\Column(name="address", type="text")
  29. */
  30. private ?string $address = null;
  31. /**
  32. * @ORM\Column(name="mobile_number", type="string", length=20)
  33. */
  34. private ?string $mobileNumber = null;
  35. /**
  36. * @ORM\ManyToOne(targetEntity="App\NewShippingBundle\Entity\Zone")
  37. */
  38. private ?Zone $zone = null;
  39. public function getFormattedFullAddress(bool $showPhoneNumber = true): ?string
  40. {
  41. $fullAddress = $this->getAddress();
  42. if ($this->getZone()) {
  43. $fullAddress .= ", " . $this->getZone()->getTitle();
  44. }
  45. if ($this->getMobileNumber() and $showPhoneNumber === true) {
  46. $fullAddress .= " - " . $this->getMobileNumber();
  47. }
  48. return $fullAddress;
  49. }
  50. public function getName(): ?string
  51. {
  52. return $this->name;
  53. }
  54. public function setName(string $name): self
  55. {
  56. $this->name = $name;
  57. return $this;
  58. }
  59. public function getEmail(): ?string
  60. {
  61. return $this->email;
  62. }
  63. public function setEmail(string $email): self
  64. {
  65. $this->email = $email;
  66. return $this;
  67. }
  68. public function getAddress(): ?string
  69. {
  70. return $this->address;
  71. }
  72. public function setAddress(string $address): self
  73. {
  74. $this->address = $address;
  75. return $this;
  76. }
  77. public function getMobileNumber(): ?string
  78. {
  79. return $this->mobileNumber;
  80. }
  81. public function setMobileNumber(string $mobileNumber): self
  82. {
  83. $this->mobileNumber = $mobileNumber;
  84. return $this;
  85. }
  86. public function getCart(): ?Cart
  87. {
  88. return $this->cart;
  89. }
  90. public function setCart(?Cart $cart): self
  91. {
  92. $this->cart = $cart;
  93. return $this;
  94. }
  95. public function getZone(): ?Zone
  96. {
  97. return $this->zone;
  98. }
  99. public function setZone(?Zone $zone): self
  100. {
  101. $this->zone = $zone;
  102. return $this;
  103. }
  104. }