Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

238 linhas
6.7KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use FOS\UserBundle\Model\User as UserModelFOS;
  7. use Lc\ShopBundle\Context\MerchantInterface;
  8. /**
  9. * @ORM\MappedSuperclass()
  10. *
  11. */
  12. abstract class User extends UserModelFOS
  13. {
  14. /**
  15. * @ORM\Column(type="string", length=20, nullable=true)
  16. */
  17. protected $phone;
  18. /**
  19. * @ORM\Column(type="string", length=64, nullable=true)
  20. */
  21. protected $behaviorDisplayPrice;
  22. /**
  23. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  24. */
  25. protected $merchant;
  26. /**
  27. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="user", orphanRemoval=true)
  28. */
  29. protected $creditHistories;
  30. /**
  31. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\AddressInterface", mappedBy="user", cascade={"persist"})
  32. */
  33. protected $addresses;
  34. /**
  35. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="user")
  36. */
  37. protected $orders;
  38. /**
  39. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CartInterface", mappedBy="user")
  40. */
  41. protected $carts;
  42. /**
  43. * @ORM\Column(type="boolean", nullable=true)
  44. */
  45. protected $isSubscribedNewsletter;
  46. public function __construct()
  47. {
  48. parent::__construct();
  49. $this->creditHistories = new ArrayCollection();
  50. $this->addresses = new ArrayCollection();
  51. $this->orders = new ArrayCollection();
  52. $this->carts = new ArrayCollection();
  53. }
  54. public function getPhone(): ?string
  55. {
  56. return $this->phone;
  57. }
  58. public function setPhone(?string $phone): self
  59. {
  60. $this->phone = $phone;
  61. return $this;
  62. }
  63. public function getBehaviorDisplayPrice(): ?string
  64. {
  65. return $this->behaviorDisplayPrice;
  66. }
  67. public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
  68. {
  69. $this->behaviorDisplayPrice = $behaviorDisplayPrice;
  70. return $this;
  71. }
  72. public function getMerchant(): ?MerchantInterface
  73. {
  74. return $this->merchant;
  75. }
  76. public function setMerchant(?MerchantInterface $merchant): self
  77. {
  78. $this->merchant = $merchant;
  79. return $this;
  80. }
  81. /**
  82. * @return Collection|CreditHistory[]
  83. */
  84. public function getCreditHistories(): Collection
  85. {
  86. return $this->creditHistories;
  87. }
  88. public function addCreditHistory(CreditHistory $creditHistory): self
  89. {
  90. if (!$this->creditHistories->contains($creditHistory)) {
  91. $this->creditHistories[] = $creditHistory;
  92. $creditHistory->setUser($this);
  93. }
  94. return $this;
  95. }
  96. public function removeCreditHistory(CreditHistory $creditHistory): self
  97. {
  98. if ($this->creditHistories->contains($creditHistory)) {
  99. $this->creditHistories->removeElement($creditHistory);
  100. // set the owning side to null (unless already changed)
  101. if ($creditHistory->getUser() === $this) {
  102. $creditHistory->setUser(null);
  103. }
  104. }
  105. return $this;
  106. }
  107. /**
  108. * @return Collection|Address[]
  109. */
  110. public function getAddresses(): Collection
  111. {
  112. return $this->addresses;
  113. }
  114. public function addAddress(Address $address): self
  115. {
  116. if (!$this->addresses->contains($address)) {
  117. $this->addresses[] = $address;
  118. $address->setUser($this);
  119. }
  120. return $this;
  121. }
  122. public function removeAddress(Address $address): self
  123. {
  124. if ($this->addresses->contains($address)) {
  125. $this->addresses->removeElement($address);
  126. // set the owning side to null (unless already changed)
  127. if ($address->getUser() === $this) {
  128. $address->setUser(null);
  129. }
  130. }
  131. return $this;
  132. }
  133. /**
  134. * @return Collection|ShopOrder[]
  135. */
  136. public function getOrders(): Collection
  137. {
  138. return $this->orders;
  139. }
  140. public function addOrder(OrderShop $order): self
  141. {
  142. if (!$this->orders->contains($order)) {
  143. $this->orders[] = $order;
  144. $order->setUser($this);
  145. }
  146. return $this;
  147. }
  148. public function removeOrder(OrderShop $order): self
  149. {
  150. if ($this->orders->contains($order)) {
  151. $this->orders->removeElement($order);
  152. // set the owning side to null (unless already changed)
  153. if ($order->getUser() === $this) {
  154. $order->setUser(null);
  155. }
  156. }
  157. return $this;
  158. }
  159. /**
  160. * @return Collection|Cart[]
  161. */
  162. public function getCarts(): Collection
  163. {
  164. return $this->carts;
  165. }
  166. public function addCart(Cart $cart): self
  167. {
  168. if (!$this->carts->contains($cart)) {
  169. $this->carts[] = $cart;
  170. $cart->setUser($this);
  171. }
  172. return $this;
  173. }
  174. public function removeCart(Cart $cart): self
  175. {
  176. if ($this->carts->contains($cart)) {
  177. $this->carts->removeElement($cart);
  178. // set the owning side to null (unless already changed)
  179. if ($cart->getUser() === $this) {
  180. $cart->setUser(null);
  181. }
  182. }
  183. return $this;
  184. }
  185. public function getIsSubscribedNewsletter(): ?bool
  186. {
  187. return $this->isSubscribedNewsletter;
  188. }
  189. public function setIsSubscribedNewsletter(?bool $isSubscribedNewsletter): self
  190. {
  191. $this->isSubscribedNewsletter = $isSubscribedNewsletter;
  192. return $this;
  193. }
  194. }