Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

295 lines
8.0KB

  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. /**
  47. * @ORM\Column(type="string", length=64, nullable=true)
  48. */
  49. protected $firstname;
  50. /**
  51. * @ORM\Column(type="string", length=64, nullable=true)
  52. */
  53. protected $lastname;
  54. /**
  55. * @ORM\Column(type="boolean", nullable=true)
  56. */
  57. protected $gender;
  58. public function __construct()
  59. {
  60. parent::__construct();
  61. $this->creditHistories = new ArrayCollection();
  62. $this->addresses = new ArrayCollection();
  63. $this->orders = new ArrayCollection();
  64. $this->carts = new ArrayCollection();
  65. }
  66. public function setEmail($email)
  67. {
  68. $this->setUsername($email);
  69. return parent::setEmail($email);
  70. }
  71. public function getPhone(): ?string
  72. {
  73. return $this->phone;
  74. }
  75. public function setPhone(?string $phone): self
  76. {
  77. $this->phone = $phone;
  78. return $this;
  79. }
  80. public function getBehaviorDisplayPrice(): ?string
  81. {
  82. return $this->behaviorDisplayPrice;
  83. }
  84. public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
  85. {
  86. $this->behaviorDisplayPrice = $behaviorDisplayPrice;
  87. return $this;
  88. }
  89. public function getMerchant(): ?MerchantInterface
  90. {
  91. return $this->merchant;
  92. }
  93. public function setMerchant(?MerchantInterface $merchant): self
  94. {
  95. $this->merchant = $merchant;
  96. return $this;
  97. }
  98. /**
  99. * @return Collection|CreditHistory[]
  100. */
  101. public function getCreditHistories(): Collection
  102. {
  103. return $this->creditHistories;
  104. }
  105. public function addCreditHistory(CreditHistory $creditHistory): self
  106. {
  107. if (!$this->creditHistories->contains($creditHistory)) {
  108. $this->creditHistories[] = $creditHistory;
  109. $creditHistory->setUser($this);
  110. }
  111. return $this;
  112. }
  113. public function removeCreditHistory(CreditHistory $creditHistory): self
  114. {
  115. if ($this->creditHistories->contains($creditHistory)) {
  116. $this->creditHistories->removeElement($creditHistory);
  117. // set the owning side to null (unless already changed)
  118. if ($creditHistory->getUser() === $this) {
  119. $creditHistory->setUser(null);
  120. }
  121. }
  122. return $this;
  123. }
  124. /**
  125. * @return Collection|Address[]
  126. */
  127. public function getAddresses(): Collection
  128. {
  129. return $this->addresses;
  130. }
  131. public function addAddress(Address $address): self
  132. {
  133. if (!$this->addresses->contains($address)) {
  134. $this->addresses[] = $address;
  135. $address->setUser($this);
  136. }
  137. return $this;
  138. }
  139. public function removeAddress(Address $address): self
  140. {
  141. if ($this->addresses->contains($address)) {
  142. $this->addresses->removeElement($address);
  143. // set the owning side to null (unless already changed)
  144. if ($address->getUser() === $this) {
  145. $address->setUser(null);
  146. }
  147. }
  148. return $this;
  149. }
  150. /**
  151. * @return Collection|ShopOrder[]
  152. */
  153. public function getOrders(): Collection
  154. {
  155. return $this->orders;
  156. }
  157. public function addOrder(OrderShop $order): self
  158. {
  159. if (!$this->orders->contains($order)) {
  160. $this->orders[] = $order;
  161. $order->setUser($this);
  162. }
  163. return $this;
  164. }
  165. public function removeOrder(OrderShop $order): self
  166. {
  167. if ($this->orders->contains($order)) {
  168. $this->orders->removeElement($order);
  169. // set the owning side to null (unless already changed)
  170. if ($order->getUser() === $this) {
  171. $order->setUser(null);
  172. }
  173. }
  174. return $this;
  175. }
  176. /**
  177. * @return Collection|Cart[]
  178. */
  179. public function getCarts(): Collection
  180. {
  181. return $this->carts;
  182. }
  183. public function addCart(Cart $cart): self
  184. {
  185. if (!$this->carts->contains($cart)) {
  186. $this->carts[] = $cart;
  187. $cart->setUser($this);
  188. }
  189. return $this;
  190. }
  191. public function removeCart(Cart $cart): self
  192. {
  193. if ($this->carts->contains($cart)) {
  194. $this->carts->removeElement($cart);
  195. // set the owning side to null (unless already changed)
  196. if ($cart->getUser() === $this) {
  197. $cart->setUser(null);
  198. }
  199. }
  200. return $this;
  201. }
  202. public function getIsSubscribedNewsletter(): ?bool
  203. {
  204. return $this->isSubscribedNewsletter;
  205. }
  206. public function setIsSubscribedNewsletter(?bool $isSubscribedNewsletter): self
  207. {
  208. $this->isSubscribedNewsletter = $isSubscribedNewsletter;
  209. return $this;
  210. }
  211. public function getFirstname(): ?string
  212. {
  213. return $this->firstname;
  214. }
  215. public function setFirstname(?string $firstname): self
  216. {
  217. $this->firstname = $firstname;
  218. return $this;
  219. }
  220. public function getLastname(): ?string
  221. {
  222. return $this->lastname;
  223. }
  224. public function setLastname(?string $lastname): self
  225. {
  226. $this->lastname = $lastname;
  227. return $this;
  228. }
  229. public function getGender(): ?bool
  230. {
  231. return $this->gender;
  232. }
  233. public function setGender(?bool $gender): self
  234. {
  235. $this->gender = $gender;
  236. return $this;
  237. }
  238. }