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.

311 lines
8.5KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\Newsletter;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use FOS\UserBundle\Model\User as UserModelFOS;
  8. use Lc\ShopBundle\Context\MerchantInterface;
  9. /**
  10. * @ORM\MappedSuperclass()
  11. *
  12. */
  13. abstract class User extends UserModelFOS
  14. {
  15. /**
  16. * @ORM\Column(type="string", length=20, nullable=true)
  17. */
  18. protected $phone;
  19. /**
  20. * @ORM\Column(type="string", length=64, nullable=true)
  21. */
  22. protected $behaviorDisplayPrice;
  23. /**
  24. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  25. */
  26. protected $merchant;
  27. /**
  28. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="user", orphanRemoval=true)
  29. */
  30. protected $creditHistories;
  31. /**
  32. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\AddressInterface", mappedBy="user", cascade={"persist"})
  33. */
  34. protected $addresses;
  35. /**
  36. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="user")
  37. */
  38. protected $orders;
  39. /**
  40. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CartInterface", mappedBy="user")
  41. */
  42. protected $carts;
  43. /**
  44. * @ORM\Column(type="string", length=64, nullable=true)
  45. */
  46. protected $firstname;
  47. /**
  48. * @ORM\Column(type="string", length=64, nullable=true)
  49. */
  50. protected $lastname;
  51. /**
  52. * @ORM\Column(type="boolean", nullable=true)
  53. */
  54. protected $gender;
  55. /**
  56. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\NewsletterInterface", inversedBy="users")
  57. */
  58. protected $newsletters;
  59. public function __construct()
  60. {
  61. parent::__construct();
  62. $this->creditHistories = new ArrayCollection();
  63. $this->addresses = new ArrayCollection();
  64. $this->orders = new ArrayCollection();
  65. $this->carts = new ArrayCollection();
  66. $this->newsletters = new ArrayCollection();
  67. }
  68. public function setEmail($email)
  69. {
  70. $this->setUsername($email);
  71. return parent::setEmail($email);
  72. }
  73. public function getPhone(): ?string
  74. {
  75. return $this->phone;
  76. }
  77. public function setPhone(?string $phone): self
  78. {
  79. $this->phone = $phone;
  80. return $this;
  81. }
  82. public function getBehaviorDisplayPrice(): ?string
  83. {
  84. return $this->behaviorDisplayPrice;
  85. }
  86. public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
  87. {
  88. $this->behaviorDisplayPrice = $behaviorDisplayPrice;
  89. return $this;
  90. }
  91. public function getMerchant(): ?MerchantInterface
  92. {
  93. return $this->merchant;
  94. }
  95. public function setMerchant(?MerchantInterface $merchant): self
  96. {
  97. $this->merchant = $merchant;
  98. return $this;
  99. }
  100. /**
  101. * @return Collection|CreditHistory[]
  102. */
  103. public function getCreditHistories(): Collection
  104. {
  105. return $this->creditHistories;
  106. }
  107. public function addCreditHistory(CreditHistory $creditHistory): self
  108. {
  109. if (!$this->creditHistories->contains($creditHistory)) {
  110. $this->creditHistories[] = $creditHistory;
  111. $creditHistory->setUser($this);
  112. }
  113. return $this;
  114. }
  115. public function removeCreditHistory(CreditHistory $creditHistory): self
  116. {
  117. if ($this->creditHistories->contains($creditHistory)) {
  118. $this->creditHistories->removeElement($creditHistory);
  119. // set the owning side to null (unless already changed)
  120. if ($creditHistory->getUser() === $this) {
  121. $creditHistory->setUser(null);
  122. }
  123. }
  124. return $this;
  125. }
  126. /**
  127. * @return Collection|Address[]
  128. */
  129. public function getAddresses(): Collection
  130. {
  131. return $this->addresses;
  132. }
  133. public function addAddress(Address $address): self
  134. {
  135. if (!$this->addresses->contains($address)) {
  136. $this->addresses[] = $address;
  137. $address->setUser($this);
  138. }
  139. return $this;
  140. }
  141. public function removeAddress(Address $address): self
  142. {
  143. if ($this->addresses->contains($address)) {
  144. $this->addresses->removeElement($address);
  145. // set the owning side to null (unless already changed)
  146. if ($address->getUser() === $this) {
  147. $address->setUser(null);
  148. }
  149. }
  150. return $this;
  151. }
  152. /**
  153. * @return Collection|ShopOrder[]
  154. */
  155. public function getOrders(): Collection
  156. {
  157. return $this->orders;
  158. }
  159. public function addOrder(OrderShop $order): self
  160. {
  161. if (!$this->orders->contains($order)) {
  162. $this->orders[] = $order;
  163. $order->setUser($this);
  164. }
  165. return $this;
  166. }
  167. public function removeOrder(OrderShop $order): self
  168. {
  169. if ($this->orders->contains($order)) {
  170. $this->orders->removeElement($order);
  171. // set the owning side to null (unless already changed)
  172. if ($order->getUser() === $this) {
  173. $order->setUser(null);
  174. }
  175. }
  176. return $this;
  177. }
  178. /**
  179. * @return Collection|Cart[]
  180. */
  181. public function getCarts(): Collection
  182. {
  183. return $this->carts;
  184. }
  185. public function addCart(Cart $cart): self
  186. {
  187. if (!$this->carts->contains($cart)) {
  188. $this->carts[] = $cart;
  189. $cart->setUser($this);
  190. }
  191. return $this;
  192. }
  193. public function removeCart(Cart $cart): self
  194. {
  195. if ($this->carts->contains($cart)) {
  196. $this->carts->removeElement($cart);
  197. // set the owning side to null (unless already changed)
  198. if ($cart->getUser() === $this) {
  199. $cart->setUser(null);
  200. }
  201. }
  202. return $this;
  203. }
  204. public function getFirstname(): ?string
  205. {
  206. return $this->firstname;
  207. }
  208. public function setFirstname(?string $firstname): self
  209. {
  210. $this->firstname = $firstname;
  211. return $this;
  212. }
  213. public function getLastname(): ?string
  214. {
  215. return $this->lastname;
  216. }
  217. public function setLastname(?string $lastname): self
  218. {
  219. $this->lastname = $lastname;
  220. return $this;
  221. }
  222. public function getGender(): ?bool
  223. {
  224. return $this->gender;
  225. }
  226. public function setGender(?bool $gender): self
  227. {
  228. $this->gender = $gender;
  229. return $this;
  230. }
  231. /**
  232. * @return Collection|Newsletter[]
  233. */
  234. public function getNewsletters(): Collection
  235. {
  236. return $this->newsletters;
  237. }
  238. public function addNewsletter(Newsletter $newsletter): self
  239. {
  240. if (!$this->newsletters->contains($newsletter)) {
  241. $this->newsletters[] = $newsletter;
  242. }
  243. return $this;
  244. }
  245. public function removeNewsletter(Newsletter $newsletter): self
  246. {
  247. if ($this->newsletters->contains($newsletter)) {
  248. $this->newsletters->removeElement($newsletter);
  249. }
  250. return $this;
  251. }
  252. }