Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

221 lines
6.3KB

  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. public function __construct()
  43. {
  44. parent::__construct();
  45. $this->creditHistories = new ArrayCollection();
  46. $this->addresses = new ArrayCollection();
  47. $this->orders = new ArrayCollection();
  48. $this->carts = new ArrayCollection();
  49. }
  50. public function getPhone(): ?string
  51. {
  52. return $this->phone;
  53. }
  54. public function setPhone(?string $phone): self
  55. {
  56. $this->phone = $phone;
  57. return $this;
  58. }
  59. public function getBehaviorDisplayPrice(): ?string
  60. {
  61. return $this->behaviorDisplayPrice;
  62. }
  63. public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
  64. {
  65. $this->behaviorDisplayPrice = $behaviorDisplayPrice;
  66. return $this;
  67. }
  68. public function getMerchant(): ?MerchantInterface
  69. {
  70. return $this->merchant;
  71. }
  72. public function setMerchant(?MerchantInterface $merchant): self
  73. {
  74. $this->merchant = $merchant;
  75. return $this;
  76. }
  77. /**
  78. * @return Collection|CreditHistory[]
  79. */
  80. public function getCreditHistories(): Collection
  81. {
  82. return $this->creditHistories;
  83. }
  84. public function addCreditHistory(CreditHistory $creditHistory): self
  85. {
  86. if (!$this->creditHistories->contains($creditHistory)) {
  87. $this->creditHistories[] = $creditHistory;
  88. $creditHistory->setUser($this);
  89. }
  90. return $this;
  91. }
  92. public function removeCreditHistory(CreditHistory $creditHistory): self
  93. {
  94. if ($this->creditHistories->contains($creditHistory)) {
  95. $this->creditHistories->removeElement($creditHistory);
  96. // set the owning side to null (unless already changed)
  97. if ($creditHistory->getUser() === $this) {
  98. $creditHistory->setUser(null);
  99. }
  100. }
  101. return $this;
  102. }
  103. /**
  104. * @return Collection|Address[]
  105. */
  106. public function getAddresses(): Collection
  107. {
  108. return $this->addresses;
  109. }
  110. public function addAddress(Address $address): self
  111. {
  112. if (!$this->addresses->contains($address)) {
  113. $this->addresses[] = $address;
  114. $address->setUser($this);
  115. }
  116. return $this;
  117. }
  118. public function removeAddress(Address $address): self
  119. {
  120. if ($this->addresses->contains($address)) {
  121. $this->addresses->removeElement($address);
  122. // set the owning side to null (unless already changed)
  123. if ($address->getUser() === $this) {
  124. $address->setUser(null);
  125. }
  126. }
  127. return $this;
  128. }
  129. /**
  130. * @return Collection|ShopOrder[]
  131. */
  132. public function getOrders(): Collection
  133. {
  134. return $this->orders;
  135. }
  136. public function addOrder(OrderShop $order): self
  137. {
  138. if (!$this->orders->contains($order)) {
  139. $this->orders[] = $order;
  140. $order->setUser($this);
  141. }
  142. return $this;
  143. }
  144. public function removeOrder(OrderShop $order): self
  145. {
  146. if ($this->orders->contains($order)) {
  147. $this->orders->removeElement($order);
  148. // set the owning side to null (unless already changed)
  149. if ($order->getUser() === $this) {
  150. $order->setUser(null);
  151. }
  152. }
  153. return $this;
  154. }
  155. /**
  156. * @return Collection|Cart[]
  157. */
  158. public function getCarts(): Collection
  159. {
  160. return $this->carts;
  161. }
  162. public function addCart(Cart $cart): self
  163. {
  164. if (!$this->carts->contains($cart)) {
  165. $this->carts[] = $cart;
  166. $cart->setUser($this);
  167. }
  168. return $this;
  169. }
  170. public function removeCart(Cart $cart): self
  171. {
  172. if ($this->carts->contains($cart)) {
  173. $this->carts->removeElement($cart);
  174. // set the owning side to null (unless already changed)
  175. if ($cart->getUser() === $this) {
  176. $cart->setUser(null);
  177. }
  178. }
  179. return $this;
  180. }
  181. }